DEV Community

Kazi Abdur Rakib
Kazi Abdur Rakib

Posted on • Edited on

ubuntu E: Unable to lock directory /var/lib/apt/lists/

rakib@pop-os:~$ sudo apt-get update
Reading package lists... Done
E: Could not get lock /var/lib/apt/lists/lock. It is held by process 1256 (packagekitd)
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/

The error message indicates that another process, with process ID 1256 (packagekitd), is currently holding the lock on the APT package lists directory. This prevents apt-get update from running.

Here are a few steps you can take to resolve this issue:

  1. Wait for the Other Process to Finish:
    It's possible that another package manager process is currently running in the background. Wait for it to complete, and then try running the update again.

  2. Check Running Processes:
    You can check which process is holding the lock using the following command:

   ps aux | grep packagekitd
Enter fullscreen mode Exit fullscreen mode

Once you identify the process, you can decide whether to wait for it to finish or take appropriate action to stop it.

  1. Terminate the Process (Caution): If the process is not critical and you are confident that it can be terminated safely, you can use the following command to kill it:
   sudo kill -9 1256
Enter fullscreen mode Exit fullscreen mode

Please be cautious when using the -9 (SIGKILL) option, as it forcefully terminates the process. This should only be used if the process is unresponsive to regular termination signals.

  1. Check for System Updates: Sometimes, system updates or installations are in progress. Ensure that your system is not in the middle of an update by checking your system update tool or wait for any ongoing updates to complete.

After addressing the issue with the lock, you should be able to run sudo apt-get update without encountering the error.

Top comments (0)