{"id":678,"date":"2017-10-04T13:00:52","date_gmt":"2017-10-04T12:00:52","guid":{"rendered":"http:\/\/chewett.co.uk\/blog\/?p=678"},"modified":"2017-10-02T22:27:32","modified_gmt":"2017-10-02T21:27:32","slug":"apt-unable-lock-administration-directory-varlibdpkg-another-process-using","status":"publish","type":"post","link":"https:\/\/chewett.co.uk\/blog\/678\/apt-unable-lock-administration-directory-varlibdpkg-another-process-using\/","title":{"rendered":"apt Unable to lock the administration directory (\/var\/lib\/dpkg\/) is another process using it?"},"content":{"rendered":"<p>This post explains why you may sometimes not be able to run apt commands and how to find out what is causing the issue.<\/p>\n<p><!--more--><\/p>\n<h2>Why apt sometimes cannot get a lock<\/h2>\n<p>apt-get is one of the package administration programs for a range of Linux based operating systems. This manages the list of packages you have installed (pieces of software). In addition this\u00a0lets you install and remove packages from all your software repositories installed.<\/p>\n<p>One of the ways this ensures that the package database is always kept in a correct state is by locking it. This ensures that only one process can be using and updating the package database at any one time.<\/p>\n<p>The standard message you get when you fail to get the lock is reproduced below.<\/p>\n<pre>Unable to lock the administration directory (\/var\/lib\/dpkg\/) is another process using it?<\/pre>\n<p>This would occur if you tried to use your package manager while another process has the lock.\u00a0Recently a number of distributions have included software that will automatically update apt. This can cause apt to be locked when you are trying to use it.<\/p>\n<h2>Checking what is using apt<\/h2>\n<p>On Ubuntu there are a number of programs that will use apt on the backend. While they are performing operations they will lock the apt database causing the error message. A couple\u00a0 possible programs that might lock apt when using it are:<\/p>\n<ul>\n<li>Ubuntu Software Center<\/li>\n<li>The Update Manager<\/li>\n<li>The apt-get or aptitude command line utilities.<\/li>\n<li>The Synaptic Package Manager<\/li>\n<\/ul>\n<p>You can use the <code>ps<\/code>\u00a0command to find out what processes are running on your machine. We can pipe the output to <code>grep<\/code>to filter out processes which might be using apt.<\/p>\n<pre>ps -e | grep -e apt -e adept | grep -v grep<\/pre>\n<p>By running\u00a0the above command I get the following command input while my apt is locked:<\/p>\n<pre>chewett@yang:~$ ps -e | grep -e apt -e adept | grep -v grep\r\n<strong>952 ? 00:00:00 apt.systemd.dai<\/strong>\r\n2673 ? 00:00:00 aptd<\/pre>\n<p>The top line is showing the primary process that is blocking apt. The full name of the executable is <code>apt.systemd.daily<\/code>.\u00a0This is a process that runs every day to update your system packages. Typically this will be running after you have turned on your computer. If this is using apt you will typically just need to wait until the update process has finished. It is not recommended to try and stop this process.<\/p>\n<p>There are ways to remove the lock from the apt database but I won&#8217;t describe them here. This is because 99.99% of the time this is a very bad idea.<\/p>\n<p>Some of the information was taken from <a href=\"https:\/\/askubuntu.com\/a\/15445\" target=\"_blank\" rel=\"noopener\">ask Ubuntu<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post explains why you may sometimes not be able to run apt commands and how to find out what is causing the issue.<\/p>\n","protected":false},"author":1,"featured_media":684,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3,5],"tags":[174,121,39,175,147],"class_list":["post-678","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fixes","category-informational","tag-apt-get","tag-debian","tag-linux","tag-package-management","tag-ubuntu"],"wppr_data":{"cwp_meta_box_check":"No"},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/10\/apt_unable_to_lock_admin_dir.jpg?fit=800%2C800&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p2toWX-aW","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":375,"url":"https:\/\/chewett.co.uk\/blog\/375\/setting-up-the-ci20-for-the-cluster\/","url_meta":{"origin":678,"position":0},"title":"Setting up the CI20 for the cluster","author":"Chewett","date":"October 27, 2018","format":false,"excerpt":"This post talks about the steps I have followed to set up my Creator CI20 for the Raspberry Pi Cluster. Burning Debian to the onboard NAND and configuring it To run the CI20 on the Raspberry Pi Cluster I am going to write Debian 8 to the NAND storage. First\u2026","rel":"","context":"In &quot;Raspberry Pi Cluster&quot;","block_context":{"text":"Raspberry Pi Cluster","link":"https:\/\/chewett.co.uk\/blog\/category\/raspberry-pi-cluster\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/10\/ci40_setup.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/10\/ci40_setup.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/10\/ci40_setup.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/10\/ci40_setup.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":453,"url":"https:\/\/chewett.co.uk\/blog\/453\/automatic-installation-commonly-used-packages\/","url_meta":{"origin":678,"position":1},"title":"Automatic installation of commonly used packages","author":"Chewett","date":"July 15, 2017","format":false,"excerpt":"A number of years ago I was introduced to using Linux day to day. During this period of time I ran a large number of virtual machines to test its performance and various aspects which make it \"linux\". Typically when I first set up a system I would install a\u2026","rel":"","context":"In &quot;Informational&quot;","block_context":{"text":"Informational","link":"https:\/\/chewett.co.uk\/blog\/category\/informational\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":572,"url":"https:\/\/chewett.co.uk\/blog\/572\/installing-ubuntu-linux-tools-windows\/","url_meta":{"origin":678,"position":2},"title":"Installing Ubuntu Linux tools for Windows","author":"Chewett","date":"August 23, 2017","format":false,"excerpt":"I am a big fan of Linux and today want to share how you can install the Windows Subsystem for Linux (WSL) on Windows 10. This new feature available in Windows 10 lets you install a Linux bash shell and run various linux tools on Windows. Here I describe how\u2026","rel":"","context":"In &quot;Informational&quot;","block_context":{"text":"Informational","link":"https:\/\/chewett.co.uk\/blog\/category\/informational\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/windows_subsystem_for_linx.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/windows_subsystem_for_linx.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/windows_subsystem_for_linx.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/windows_subsystem_for_linx.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":461,"url":"https:\/\/chewett.co.uk\/blog\/461\/updating-raspberry-pi-cluster-without-logging-every-pi\/","url_meta":{"origin":678,"position":3},"title":"Updating the Raspberry Pi Cluster without logging in to every Pi","author":"Chewett","date":"July 1, 2017","format":false,"excerpt":"The Raspberry Pi foundation have recently updated their Raspbian image. This brings bugfixes and upgrades to the Raspberry Pi. In this blogpost I share how you can run a command on your Raspberry Pi without logging in (this is mostly true although you still do \"log in\" just not in\u2026","rel":"","context":"In &quot;Raspberry Pi Cluster&quot;","block_context":{"text":"Raspberry Pi Cluster","link":"https:\/\/chewett.co.uk\/blog\/category\/raspberry-pi-cluster\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/07\/raspbian_update_command.png?fit=580%2C307&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/07\/raspbian_update_command.png?fit=580%2C307&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/07\/raspbian_update_command.png?fit=580%2C307&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":409,"url":"https:\/\/chewett.co.uk\/blog\/409\/setting-raspberry-pi-cluster-node\/","url_meta":{"origin":678,"position":4},"title":"Setting up a Raspberry Pi Cluster Node","author":"Chewett","date":"August 19, 2017","format":false,"excerpt":"To set up a Raspberry Pi node I will follow a specific set of steps so that every Pi is set up \u00a0similarly. For the initial deployment I will follow this once and then clone the SD Card multiple times. If at a later date more are added I will\u2026","rel":"","context":"In &quot;Raspberry Pi Cluster&quot;","block_context":{"text":"Raspberry Pi Cluster","link":"https:\/\/chewett.co.uk\/blog\/category\/raspberry-pi-cluster\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/setting_up_a_raspi_cluster_node.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/setting_up_a_raspi_cluster_node.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/setting_up_a_raspi_cluster_node.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2017\/08\/setting_up_a_raspi_cluster_node.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1675,"url":"https:\/\/chewett.co.uk\/blog\/1675\/how-to-install-python-pip-on-ubuntu-18-04-server\/","url_meta":{"origin":678,"position":5},"title":"How to install Python Pip on Ubuntu 18.04 Server","author":"Chewett","date":"October 24, 2018","format":false,"excerpt":"This post describes how you can install Python Pip on ubuntu 18.04. Why apt doesn't work immediately By default the server edition of Ubuntu only includes the main repository for the Ubuntu software. This is for various performance and security reasons but means that there are a number of packages\u2026","rel":"","context":"In &quot;Informational&quot;","block_context":{"text":"Informational","link":"https:\/\/chewett.co.uk\/blog\/category\/informational\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/10\/installing_pip_ubuntu_server-1.jpg?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/10\/installing_pip_ubuntu_server-1.jpg?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/10\/installing_pip_ubuntu_server-1.jpg?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/chewett.co.uk\/blog\/wp-content\/uploads\/2018\/10\/installing_pip_ubuntu_server-1.jpg?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=678"}],"version-history":[{"count":5,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/678\/revisions"}],"predecessor-version":[{"id":683,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/posts\/678\/revisions\/683"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/media\/684"}],"wp:attachment":[{"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chewett.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}