How to Fix: Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?

- Advertisment -
- Advertisement -

Many times in Ubuntu Linux the apt-get command stuck in somewhere while installing or performing some commands in the Ubuntu terminal. The  error you get in the apt-get which is package management tool in Ubuntu are:

E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?

These errors are so annoying that a new Ubuntu Linux user might get frustrated and think that the Linux is not meant for him/her. But everything has a solution and this too, Linux operating system is wonderful because you can modify and use as per your choice.

Unlock the administration directory (/var/lib/dpkg/) in Ubuntu

For this tutorial, we are using Ubuntu 17.04.

Here are some other error examples you might be faced: 

E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/ 
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable) 
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

Login as Root

Step 1: First of all you should have root access to your Ubuntu Linux to unlock the locked apt-get.

Step 2: Switch to root using the command

su

and enter the password for the root user.

Command To find the Process uses the APT

Step 3:  The errors shown above are because there would some process running in the background that has locked the apt and we need to find out which process using it.

To find out all apt-get or apt processes use the following command:

ps aux | grep apt

Command To find adn kill Process uses the APT

This command will show all the active process and those using apt. Now find the process those showing the apt in red colour as shown in the above screenshot. You will see a process ID (PID) of each process in the first column. Just write down all the process IDs of processes using the apt (red in colour) command.

Kill the Process in Ubuntu Terminal

Step 4: Replace the ProcessID with the ID you noted in the previous step those has locked and uses the apt.

sudo kill -9 processID
OR
sudo kill -SIGKILL processID

For example, in step 3 of this tutorial, the two process uses the apt is 3499. Now, if we want to kill it to unlock the apt, we use the command in this form:

sudo kill -9 3499

or 

sudo kill -SIGKILL 3499

Clear the Lock Files

If the error still persists then you need to remove the lock files created under the /var/lib/dpkg/ directory.

sudo rm /var/lib/dpkg/lock
sudo dpkg --configure -a

And if the lock files are under the /var/lib/apt/lists/ directory then use these commands to remove:

 sudo rm /var/lib/apt/lists/lock
 sudo rm /var/cache/apt/archives/lock

After removing the above lock files run the update command to see the apt-get is working or not…

sudo apt-get update

 

If you have any questions or doubt let us know…

H2S Media Team
H2S is a group of tech enthusiasts those are passionate about latest technology developments. They always like to solve own technical problems and share the same solution with others through this Website.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Posts

Harmano launches Air Flex Pro Foldable TWS Bluetooth earphones

Harmano, that deals in audio products recently has announced its Neckband earphones "Air Flex Pro" which provides protection Sweatproof...

How to rearrange the Chrome Duet menu on Chrome 80 for Android

If Google Chrome is the browser of your choice on Android, you might have experienced the new Chrome-Duet menu...

How to set different default folders for Downloads & Media files on Windows

When we start using our Windows computer the default folder for storing the Downloads, Documents, Pictures, Videos, and everything...

How to install Ubuntu Cinnamon Remix 19.10 on Virtual box or PC

The Ubuntu distribution of Linux doesn’t need an introduction, and it is the favourite Linux distribution of many users,...
- Advertisement -

How to open 4 or more than 4 Windows Explorer locations on PC

When we use our computers running Windows, copying and moving files from one location to the other is something...

Top 5 Classic games that you should download on your Android mobile

Thanks to the powerful Android phones that we have in our hands in 2020, we can run a lot...

- Advertisment -
- Advertisement -

You might also likeRELATED
Recommended to you