dpkg frontend lock

Post Reply
andawriter
Posts: 8
Joined: Mon Dec 14, 2020 8:59 am

Hello Friends,

I need help.

After inputting all the pre-installation info via ssh, and the installation is about to proceed (Installation will take about 15 minutes...)

I got this error message on Putty 👇

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
Error: apt-get upgrade failed

So the installation stopped.
I'm using a dedicated server. Prior the installation of myvestacp (my top choice among open source panels), I ran a sudo upgrade and update command of Debian 10. Everything was fine until I got the error above.

Thank you for any help. And thank you to the kind founder of myvestacp for your work on this fork.
User avatar
myVesta
Site Admin
Posts: 928
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 8 times
Been thanked: 6 times

You obviously have some 'apt' proccess that get locked in background.

Try to unlock it by following this: https://itsfoss.com/could-not-get-lock-error/

----------------------------------
In short:

In your ssh, as root, run:

Code: Select all

ps aux | grep -i apt
You will see output like this:

Code: Select all

root      8134  0.1  0.7  70252 58800 pts/0    S+   20:25   0:03 apt upgrade
In this example we see process 8134
Now we will kill that process:

Code: Select all

sudo kill 8134
sudo kill -9 8134
And re-run upgrade process by doing:

Code: Select all

sudo dpkg --configure -a
The above command would continue upgrading process in most cases.

But, if you are still locked, then:

Run these commands one by one:

Code: Select all

sudo lsof /var/lib/dpkg/lock
sudo lsof /var/lib/apt/lists/lock
sudo lsof /var/cache/apt/archives/lock
It’s possible that the commands don’t return anything, or return just one number. If they do return at least one number, use the number(s) and kill the processes like this (replace the <process_id> with the numbers you got from the above commands):

Code: Select all

sudo kill -9 <process_id>
You can now safely remove the lock files using the commands below:

Code: Select all

sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock
After that, re-run upgrade process again:

Code: Select all

sudo dpkg --configure -a
The above command would continue upgrading process

--------------------------

p.s. Check if you are running 'apt' as root?
andawriter
Posts: 8
Joined: Mon Dec 14, 2020 8:59 am

I wish to publicly thank Sir Dpeca, the founder of myVestacp, for his kindness and for his time in helping me fixed this issue. All the websites that provide solutions to the above error were not enough to fix the problem.

Dpeca suggested this solution before executing the installation script:

Code: Select all

sudo bash
cd ~
User avatar
myVesta
Site Admin
Posts: 928
Joined: Fri Jun 19, 2020 9:59 am
Has thanked: 8 times
Been thanked: 6 times

Yes, because you were not 'root' but local user, and that's why apt was locked.
Post Reply