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?

Kulfy
  • 17,696

2 Answers2

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

Soren A
  • 6,799
Suhas R
  • 11
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.

Caleb
  • 41