Could not open lock file/var/lib/dpkg/lock [How to Solve]

Today, when installing redis in Ubuntu, the following error occurred when executing the apt get - y install redis server command:

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?

Possible causes:

The apt get command was used to install a resource before, but terminal was closed before the installation was completed. When it was opened again, another process was occupying the apt get install process. Because the system lock during software source update will be occupied during operation, an error will be reported.

Solution, run the following four commands in sequence:

sudo rm -rf /var/lib/dpkg/lock
sudo rm -rf /var/cache/apt/archives/lock
sudo apt-get update
sudo dpkg --configure -a

Similar Posts: