Skip to main content

Logging into the server, and there are packages to be updated.  You know the standard Ubuntu / Linux response

5 updates can be applied immediately.
To see these additional updates run: apt list --upgradable

3 additional security updates can be applied with ESM Apps.
Learn more about enabling ESM Apps service at https://ubuntu.com/esm

Followed by the action

sudo apt update && sudo apt upgrade -y

 Response

Reading package lists... Done
E: Could not get lock /var/lib/apt/lists/lock. It is held by process 2003293 (apt-get)
N: Be aware that removing the lock file is not a solution and may break your system.
E: Unable to lock directory /var/lib/apt/lists/

This just means that there is an application using apt.  First try to find out which application it is by using this command in the terminal

ps aux | grep '[a]pt'

If there is a process running using apt (as noted in the error apt-get is being used), it's recommended to let it finish what its doing. Otherwise you can kill it using

kill <PID of the process (2nd column in output of ps aux)>

Ensure there is no process or killing it, if ok - you can remove the lock using

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

 

Related articles