Not Using Locking for Read Only File /var/lib/dpkg/lock
Introduction
In Ubuntu, y'all may sometimes encounter an error when attempting to run an apt
command:
Could not get lock /var/lib/dpkg/lock – open (xi: Resource temporarily unavailable)
Eastward: Unable to lock the administration directory (/var/lib/dpkg/), is another procedure using it?
This message lets you know that dpkg, the Debian Packet Manager service, is unavailable.
Use the options in this guide to resolve the Ubuntu "Could non get lock…" error.
Prerequisites
- Access to a terminal window / control line
- A user account with sudo or root privileges
5 Options to Fix "Could non get lock" Ubuntu Error
By default, the update service launches when Ubuntu starts. The automatic updater uses dpkg to cheque and install updates.
The dpkg service locks itself so that two processes don't update the content simultaneously. The service is locked to avoid potential corruptions in the system. Withal, it too means that the user cannot, for example, run a simple apt
command.
one: Wait it Out or Reboot
Give the system upwardly to 10 minutes afterwards you lot see the fault, then try your software installation again.
If you lot're certain that nothing is being installed, you can reboot the motorcar and try again.
To suit the settings for automatic updates:
ane. Click Activites > Search.
2. Type Updates.
3. Click the icon for Software & Updates.
iv. Use the check boxes and drib-down menus to select your preferred update schedule.
Note: We recommend keeping automatic updates turned on. Optionally, you can set up them to exist less frequent or to notify you instead of automatic downloading.
2: Examine the Running Processes
1. If you lot already tried waiting and rebooting the system, and you withal get the error, apply the post-obit command to see which installation services are running:
ps aux | grep -i apt
2. If there are whatsoever applications using apt, they volition announced on the list. Await for an entry like to:
/usr/lib/apt/apt.systemd.daily update
3. The daily update
bulletin ways your system is running normal updates. Y'all have to wait for this process to cease, but no other activeness is required.
Y'all may have another apt process that'southward running:
root 2810 0.0 0.0 72948 4312 pts/0 S+ 15:03 0:00 sudo apt-get remove logstash
The virtually important columns are the second cavalcade, which lists the PID (process ID), and the last column that displays the service that'due south using apt.
four. Alternately, y'all may take a dpkg service that's still running. To find it, use the post-obit control:
ps aux | grep -i dpkg
The dpkg output will look similar to the apt output.
three: Address the Stuck Apt Service
ane. If y'all take a mystery apt or dpkg service running, terminate it and see if that resolves your error. Use the following control:
sudo kill 8808
ii. Supervene upon 8808
with the bodily process ID (PID) from Step ii. It should complete and render to a new command prompt line. If it doesn't, strength the process to stop by adding the -9
selection:
sudo kill -9 8808
This should take resolved the upshot.
4: Delete Lock Files
The error message in Ubuntu may announced similar to the following:
/var/lib/dpkg/lock /var/lib/dpkg/lock-frontend /var/lib/apt/lists/lock /var/enshroud/apt/athenaeum/lock
These are lock files, which are created to prevent 2 instances of apt or dpkg from using the aforementioned files at the same time. This tin happen if an installation is interrupted or did non complete. Remove the lock files at your ain take chances.
To delete the lock files, use the rm
command:
sudo rm /var/lib/dpkg/lock sudo rm /var/lib/apt/lists/lock sudo rm /var/cache/apt/athenaeum/lock
Removing these files should set up the fault.
v: Reconfigure dpkg
ane. Run the --configure
command if you just deleted the lock files. Besides, this control will aid if you receive the following error:
"dpkg was interrupted, you must manually run 'sudo dpkg –configure -a' to correct the trouble."
2. Enter the command equally displayed above:
sudo dpkg --configure -a
Output returns a new line and the command should resolve the issue.
Fix Could not get lock /var/lib/dpkg/lock-frontend Error
The steps for fixing this error follow the like blueprint in the methods nosotros described above. The full mistake is:
E: Could not become lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable) Due east: Unable to learn the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is some other process using it?
1. Practise not remove the lock files immediately. Before doing and so, locate and kill all processes that may be using the files.
sudo lsof /var/lib/dpkg/lock-frontend
two. The output returns a upshot similar to:
lsof: Alert: can't stat() fuse.gvfsd-fuse file system /run/user/yard/gvfs Output data may be incomplete. lsof: WARNING: can't stat() fuse file system /run/user/chiliad/doc Output information may be incomplete. Control PID USER FD TYPE DEVICE SIZE/OFF NODE NAME unattende 1127 root 2oW REG vii,2 0 165231 /var/lib/dpkg/lock-frontent
3. If y'all run across unattended
under the control column, your system is installing a security update. Wait for the procedure to complete.
four. Otherwise, note all process IDs and kill them with the force selection:
sudo kill -9 process_id
v. One time you do that, y'all can try removing the lock-frontend files.
sudo rm /var/lib/dpkg/lock-frontend
This should fix the fault.
6. The last affair yous tin can try later deleting the lock files is reconfiguring dpkg every bit we showed in the fifth section.
sudo dpkg --configure -a
To test if these steps stock-still the fault, run the update command:
sudo apt update
When the process completes successfully, that shows you stock-still the "Eastward: Could not become lock /var/lib/dpkg/lock" fault.
Note: The fault we tackled has multiple different forms, merely the methods for fixing information technology are similar. Some of the variations of the "Could not become lock…" error are:
East: Could not become lock /var/lib/apt/lists/lock – open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
and
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 some other process using it?
Determination
This article explains five options to fix the "Due east: Could not get lock /var/lib/dpkg/lock" mistake on Ubuntu.
I of the options in a higher place will resolve the issue and chances are that the mistake will resolve itself upon rebooting the system.
Another common Ubuntu error bulletin "Sub-process /usr/bin/dpkg returned an fault code (1)" could indicate a problem with the bundle installer.
Was this article helpful?
Yes No
Source: https://phoenixnap.com/kb/fix-could-not-get-lock-error-ubuntu
0 Response to "Not Using Locking for Read Only File /var/lib/dpkg/lock"
Post a Comment