-1

When I try to update packages, I am getting the following:

sudo apt-get update
Reading package lists... Done
E: Could not get lock /var/lib/apt/lists/lock. It is held by process 1981 (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/

After waiting for some time, I am getting the same issue. After losing patience I killed the process id 1981 and am getting the same issue again.

I checked the pid status with:

➜  ~ ps u --pid 1981
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root      1981  0.0  0.2  13768  8448 pts/6    T+   22:34   0:00 apt-
above is the status 

Please guide me through this as I am a beginner. Any resources would be really appreciated.

Gogeta70
  • 267
  • 2
  • 7
mat
  • 1
  • 1
  • 3
    Does this answer your question? [Could not get lock /var/lib/apt/lists/lock](https://askubuntu.com/questions/335794/could-not-get-lock-var-lib-apt-lists-lock) This means something else is using apt. You need to wait for it to finish. If it doesn't, then reboot your computer. If it still doesn't resolve, delete the lock file as a last resort. – Nmath Apr 19 '23 at 18:19

1 Answers1

-1

It looks like your system was running an update in the background and you killed the process mid-update. I'd advise against doing this as it can break your system.

To proceed, since you already killed the process, go ahead and delete the file /var/lib/apt/lists/lock. You'll need to do it as root, so run this command: sudo rm /var/lib/apt/lists/lock.

Next, to make sure your system isn't broken and to try to fix any broken or half-installed packages, run this command: sudo apt-get -f install. This should resume where the process you killed left off, hopefully.

Gogeta70
  • 267
  • 2
  • 7