An error comes up in the process of installing a package in an Ubuntu Linux Distribution Operating System which is specified as shown in the title of this article. The error message is : Could not get lock /var/lib/dpkg/lock – open (11 Resource temporary unavailable).
The cause of the error is strongly assumed which can be actually a fact that the previous execution of the command for modifying an Ubuntu package is being terminated halfway in the process. In case of this article, the context is for removing the package which has already installed. The command which is carried out for being executed is shown below :
apt remove --purge [package_name]
So, the following are details on the installation process :
root@hostname:~# apt remove --purge mysql-server-5.6 Reading package lists... Done Building dependency tree Reading state information... Done Package 'mysql-server-5.6' is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 46 not upgraded. 2 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Setting up mysql-server-5.7 (5.7.19-0ubuntu0.16.04.1) ... Renaming removed key_buffer and myisam-recover options (if present) z + Stopped apt remove --purge mysql-server-5.6 root@hostname:~#
The above process is a process which is executed for safely removed specific program name or package specified. It will actually remove almost everything related to the package name, but not all the dependencies installed with it on installation. The above command is an attempt to remove or to clean mysql-server which is being the culprit of dependency bug installation. So, it need to be cleaned or removed entirely.
The attempt is for wanting to ‘start all over’ with a proper and configured application because it caused lots of troubled since the upgrade process of mysql-server which involved some sort of dependency bug messed up the configuration. However, since it does not remove configuration or data files residing in users data directories of MySQL, the above command is persecuted. There is no easy way to get those removed as well. The name of the package itself is specifically passed as an argument to the command which in the context of this article it is ‘mysql-server-5.6.
As shown in the output execution of the command since it took too long, it is cancelled by typing the Ctrl+Z and in the end it cause the other attempt for removing the package is failed as shown in the following output :
root@hostname:~# apt remove --purge mysql-server-5.7 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? root@hostname:~#
As stated in the previous output, there is an incomplete process which is carried out by apt command so in order to solve the above problem the following steps are taken :
root@hostname:~# rm -rv /var/cache/apt/archives/lock removed '/var/cache/apt/archives/lock' root@hostname:~# rm -rv /var/lib/dpkg/lock removed '/var/lib/dpkg/lock' root@hostname:~#
And continue on the process involving apt command, below is the command executed :
root@hostname:~# apt remove --purge mysql-server-5.7 Reading package lists... Done Building dependency tree Reading state information... Done The following packages will be REMOVED: mysql-server* mysql-server-5.7* 0 upgraded, 0 newly installed, 2 to remove and 46 not upgraded. 2 not fully installed or removed. After this operation, 48,5 MB disk space will be freed. Do you want to continue? [Y/n] Y