In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to fix the "Unable to lock the administration directory (/var/lib/dpkg/)" problem in Ubuntu. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.
When using the apt-get command in Ubuntu or its derivatives such as Linux Mint(a system I already use as a routine) or its relatively newer APT administration tool, you may see an error on the command line saying unable to lock the administration directory (/var/lib/dpkg/) is another process using it.
This error is especially annoying for Linux(Ubuntu) novices who are unaware of the cause of this error.
Here is an example of a file lock error that appears on Ubuntu 16.10:
tecmint@TecMint:~$ sudo apt install neofetch [sudo] password for tecmint: 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?
The following output is another error that might be displayed:
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?
How will you solve this mistake in the future? There are several ways to deal with this error, but in this article we'll use two of the simplest and most effective ways to fix it.
Find and kill all apt-get or apt processes
Run the following command to generate a list of all processes that contain apt. You can use ps and grep commands and pipe combinations to get processes that contain apt or apt-get.
$ ps -A | grep apt
Find apt and apt-get processes
As you can see from the output of the above command for each apt-get or apt process, use the following command to kill each process.
The *** column in the screenshot above is the process ID(PID).
$ sudo kill -9 processnumber or $ sudo kill -SIGKILL processnumber
For example, 9 in the following command is the number of SIGKILL signals that will kill *** apt processes:
$ sudo kill -9 13431 or $ sudo kill -SIGKILL 13431
2. Delete locked files
Locked files block access to certain files or data in Linux, a concept that also exists in Windows and other operating systems.
Once you run apt-get or apt, lock files will be created in/var/lib/apt/lists/,/var/lib/dpkg/,/var/cache/apt/archives/.
This helps running apt-get or apt processes avoid being interrupted by other user or system processes that need to use the same file. When the process is complete, the lock file is deleted.
Important caveat: in case you see locked files in two different folders above without seeing apt-get or apt processes, this is because the process was killed for some reason, so you need to delete the locked files to avoid this error.
First run the following command to remove the locked files from the/var/lib/dpkg/folder:
$ sudo rm /var/lib/dpkg/lock
Then force a reconfiguration of the package like this:
$ sudo dpkg --configure -a
You can also delete locked files under/var/lib/apt/lists/and cache folders:
$ sudo rm /var/lib/apt/lists/lock $ sudo rm /var/cache/apt/archives/lock
Next, update your package source list:
$ sudo apt update or $ sudo apt-get update Thank you for reading! About "How to fix the"Unable to lock the administration directory (/var/lib/dpkg/)"problem in Ubuntu" This article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.