Array

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

Zebronics launches ZEB-Juke Bar 9000 sound bar with Dolby Digital Plus

Zebronics that has been working in the audio industry for a very long time recently has launched its new...

List of Best SQL Server Monitoring Tools with free trial in 2020

Monitoring database server not only for SQL but all kind of database systems is really a crucial task and need...

How to run Chrome extensions on Microsoft Edge Chromium browser

It is long since we know about Microsoft Edge, which is Microsoft's endeavour to dominate the market of browsers....

How to get dark mode on WhatsApp to keep eyes stress free

WhatsApp keeps adding new features to the app, and most features turn out to be useful for us, except...
- Advertisement -

73% of software developers willing to invest Rs 10-20k per year for upskilling

The rapid development in the technology area is compelling the firms and developers to gear up their technology skills...

Sony accidentally confirmed a massive News leak on PS5

The PlayStation 5 launch is just around the corner. Also, the rumours are about an upcoming meeting of Sony...

- Advertisment -
- Advertisement -

You might also likeRELATED
Recommended to you