Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux prompts Could not get lock / var/lib/dpkg/lock to report an error what to do

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is to share with you about Linux prompts Could not get lock / var/lib/dpkg/lock to report an error. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Prompt Could not get lock / var/lib/dpkg/lock to report an error?

Some partners may encounter errors such as the following when updating or installing software using apt package Manager:

E: Could not get lock / var/lib/dpkg/lock-frontend-open (11: Resource temporarily unavailable) E: Unable to acquire the dpkg frontend lock (/ var/lib/dpkg/lock-frontend), is another process using it?

Or

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? E: Could not get lock / var/lib/apt/lists/lock-open (11: Resource temporarily unavailable) E: Unable to lock directory / var/lib/apt/lists/

At this time, there is no need to panic, these error tips are generally because some programs are doing some apt operations in the background of the system, so the apt database is locked, so apt operations cannot be carried out for the time being.

Solution

Well, in this case, usually we only need to wait quietly for a few minutes, or do other things first, such as browsing through the articles in Liangxu Linux official account, until the current update, installation or uninstall task is completed, the lock will be automatically released, and then we can apt.

Of course, the above is the corresponding under normal circumstances, which is abnormal, for example, if you have waited for a few minutes and the lock has not been released, you have to see if the process is stuck for some reason and has been occupying the lock. If so, then you can only kill the process and then delete the lock.

First, let's find out which process is occupying the lock file / var/lib/dpkg/lock.

$sudo lsof / var/lib/dpkg/lock

Commands corresponding to other lock files

$sudo lsof / var/lib/dpkg/lock-frontend $sudo lsof / var/lib/apt/lists/lock

And then get the output.

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME unattende 1548 root 6uW REG 8,2 0 1181062 / var/lib/dpkg/lock

As we can see from the results, the PID of the process is 1548

Next, kill drops the process.

$sudo kill-9 1548

Then you can safely delete the lock file.

$sudo rm / var/lib/dpkg/lock

Or

$sudo rm / var/lib/dpkg/lock-frontend $sudo rm / var/lib/apt/lists/lock

If necessary, you can also delete the lock file in the cache directory

$sudo rm / var/cache/apt/archives/lock

After completing the above steps, remember to run the following command

$sudo dpkg-configure-a

So the problem should be solved.

Thank you for reading! This is the end of the article on "how to report an error in Could not get lock / var/lib/dpkg/lock in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report