Error “E: Could not access the lock file /var/lib/dpkg/lock” in Kali Linux (SOLVED)
Sometimes when using the package manager apt to install a program or update packages, an error occurs:
E: Could not access the lock file /var/lib/dpkg/lock - open (11: The resource is temporarily unavailable) E: The control directory could not be locked (/var/lib/dpkg/); is it already being used by another process?
On the Internet, this error was often discussed, but I decided to return to its solution, because it is usually given the wrong advice that you need to remove /var/lib/dpkg/lock. If there was no emergency shutdown of the package manager apt, you do not need to delete the locking files. This will cause apt to report an error on subsequent use and have to run a command to repair packages.
The reason of the error is that apt already is working in the background - most likely, it is just downloading the update packages, because by default apt does not upgrade.
For other distributions, this causes a temporary inconvenience, since you need to wait until apt completes its background tasks. If it needs to download many packages, and the Internet connection is slow, then you will have to wait a long time. For Kali Linux, a specialized distribution, this behavior may be unacceptable for someone. By the way, the maintainers of Kali Linux claim that by default the all network services are disabled. Nevertheless, apt can still automatically download updates in the background when you are not aware.
The fact is that, for example, the desktop environment (GNOME) can run apt in the background. I seem to have found all the settings, after disabling which apt will never download anything without your permissions. If after following this guide you still have an error “Could not access the lock file /var/lib/dpkg/lock - open (11: The resource is temporarily unavailable)”, give me to know in the comment section - we will dig deeper.
So, we start with the most obvious, turn off the download of updates on a schedule. To check whether any automatic updates are enabled, you can use the command:
systemctl list-unit-files | grep enabled | grep apt
To disable them:
sudo systemctl disable apt-daily-upgrade.timer sudo systemctl disable apt-daily.timer
Now disable Unattended updates, open the /etc/apt/apt.conf.d/20auto-upgrades file:
sudo gedit /etc/apt/apt.conf.d/20auto-upgrades
it has the following lines:
APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "1";
The first is responsible for updating the list of packages, and the second one is for updating the packages themselves in the system. Replace 1s with 0s.
Now check whether GNOME is configured to do automatic updates:
gsettings get org.gnome.software download-updates
If true is printed, then yes, the desktop environment also downloads updates in the background.
To disable this, run:
sudo gsettings set org.gnome.software download-updates false
Last Updated on
- How to install a package for which there is no dependency of the required version (in Kali Linux, Debian) (82.3%)
- Kali Linux updating troubleshooting (82.3%)
- Error in Kali Linux ‘The following signatures were invalid’ (SOLVED) (76.4%)
- testssl.sh: No cipher mapping file found and No TLS data file found (SOLVED) (58.7%)
- Kali Linux web server shows blank pages (SOLVED) (58.7%)
- How to use PsExec tools to run commands and manage remote Windows systems (RANDOM - 50%)