Fix E: Could not get lock /var/cache/apt/archives/lock [Quick Tip]

Problem:

The other day a reader asked me that she had troubles with this kind of error:

E: Could not get lock /var/cache/apt/archives/lock – open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/cache/apt/archives/

She was trying to follow one of the tips mentioned in things to do to after installing Ubuntu 14.04ย when she encountered this error. Its one of the common occurring update errors in Ubuntu and also one of the least annoying ones.

Reason:

If you are wondering what caused this error in the first place, the reason is quite evident in the error itself. The error says:ย Could not get lock /var/cache/apt/archives/lock – open (11: Resource temporarily unavailable). And this is what precisely happening.

While you are trying to install some package with apt command, some other package manager is running or an update is going on.

It is possible that you have Software Center open or another terminal is using the apt or apt-get commands.

Solution:

The first and foremost thing is to do nothing. I mean once the other program that is using the resource completes the process, the resources will be available again.

Otherwise, look for other programs that might be using apt. Close that program.

You can also search if there is an instance of apt command running (use ps aux | grep -i apt) and then kill the process.

An easier way to do that would be to use the killall command:

sudo killall apt-get

If the above commands don’t fix the issue of E:ย Could not get lock /var/cache/apt/archives/lock – open (11: Resource temporarily unavailable), try the following commands one by one to fix the issue:

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

The above commands remove the lock files and thus apt and dpkg packag management process are free to be used again.ย Though not necessary, you may need to reconfigure dpkg with the command below:

sudo dpkg --configure -a

I hope this quick tip helps in solving this common update error in Ubuntu. Any questions or suggestions are welcomed. Ciao :)

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries ๐Ÿ•ต๏ธโ€โ™‚๏ธ

Become a Better Linux User

With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

It's FOSS

Great! Youโ€™ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.