Unable to lock the administration directory (/var/lib/dpkg/) ?

I got this error when trying to use


We get this message if you forget to use sudo when executing an apt command. It is also a sign that something else is installing or removing software and has locked the apt database while performing action. The programs that can do this are:

The Software Center
The Update Manager
The apt link installer (I think this now goes through SC)
The apt-get or aptitude command line utilities.

You can force the lock off by removing the file, but it’s recommended to first close the program holding the lock safely. Else you could cause corruption or interrupt an installation (bad). You can also kill the process by using following:

ps aux | grep apt
kill processnumber
kill -9 processnumber

These will kill the process and remove the lock. If still not working, you can delete the lock using following command:

sudo fuser -cuk /var/lib/dpkg/lock
 sudo rm -f /var/lib/dpkg/lock

And the same command can be used for the apt cache lock:

sudo rm /var/lib/apt/lists/lock
sudo fuser -cuk /var/cache/apt/archives/lock
sudo rm -f /var/cache/apt/archives/lock

In this way, you can get out of this.


Published by


I am the one who discover myself daily through reading, writing, interacting with people and expressing my thoughts to inspire them if I would be able to bring a little change to the society through my work. I write blogs, participate in various social activities and want to be a Professional Speaker. Currently, I am pursuing my post graduation in Computer Applications from Guru Nanak Dev Engineering College, Ludhiana and I’m very much active in many technical & social communities.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s