3

I am trying to run sudo apt-get upgrade but it is showing the below error message:

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (2: No such file or directory)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

Here are the solutions I have tried :

  1. I have tried, "sudo apt-get update"
  2. I have also tried to delete the locked files using the commands:

    sudo rm -r /var/lib/dpkg/lock-frontend
    sudo rm -rf /var/lib/dpkg/lock
    

    but it is showing the error that "no so such file or directory".

  3. I tried to kill all the running process using the command:

    ps aux | grep -i apt    
    sudo kill -9 <process id>
    sudo killall apt apt-get
    

How can I solve this issue?

8
  • What is the output of ls -l /vat/lib/dpkg/? Looks like something is missing. Commented May 9, 2019 at 7:40
  • it is showing the error message: ls: cannot access '/vat/lib/dpkg/': No such file or directory Commented May 9, 2019 at 7:47
  • Oh sorry for the typo. It's ls -l /var/lib/dpkg/. Commented May 9, 2019 at 7:50
  • same error message .. : ls: cannot access '/var/lib/dpkg/': No such file or directory Commented May 9, 2019 at 7:51
  • 2
    Try this sudo mkdir -p /var/lib/dpkg/{alternatives,info,parts,triggers,updates}; sudo touch /var/lib/dpkg/status; sudo apt install dpkg Commented May 9, 2019 at 8:56

2 Answers 2

1

The right solution is pasted below, run the below commands and it should fix the problem.

sudo mkdir -p /var/lib/dpkg/{alternatives,info,parts,triggers,updates}

sudo cp /var/backups/dpkg.status.0 /var/lib/dpkg/status

apt-get download dpkg

sudo dpkg -i dpkg*.deb

apt-get download base-files

sudo dpkg -i base-files*.deb

sudo apt-get update

sudo apt-get check
1
  • it worked perfectly, should be an accepted answer Commented Feb 26, 2024 at 19:59
0

You most likely have another process that is using the package manager.

Close any other terminal instances and any GUI package managers. If you are not sure which process/program currently has those privileges, a reboot should fix the problem.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.