Howto Fix E: Unable to lock directory /var/cache/apt/archives/

Howto Fix E: Unable to lock directory /var/cache/apt/archives/

ubuntu

 

Step 1: Error we are getting

root@ip-10-48-234-13:~# apt-get install postfix
Reading package lists… Done
Building dependency tree
Reading state information… Done
Suggested packages:
procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin dovecot-common postfix-cdb mail-reader postfix-doc
The following NEW packages will be installed:
postfix
0 upgraded, 1 newly installed, 0 to remove and 72 not upgraded.
E: Could not get lock /var/cache/apt/archives/lock – open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/cache/apt/archives/

Step 2: How to fix that error on your Ubuntu

Show all process related to apt-get

root@ip-10-48-234-13:~# ps -ef | grep apt-get
root 1256 1212 0 22:31 pts/0 00:00:00 /usr/bin/perl -w /usr/share/debconf/frontend /usr/bin/debconf-apt-progress — apt-get -q -y install mail-server^
root 1262 1256 0 22:31 pts/0 00:00:00 /usr/bin/perl -w /usr/bin/debconf-apt-progress — apt-get -q -y install mail-server^
root 1265 1262 0 22:31 pts/0 00:00:01 [apt-get] <defunct>
root 1598 1480 0 22:39 pts/1 00:00:00 grep –color=auto apt-get

Kill all process related to apt-get

root@ip-10-48-234-13:~# kill -9 1256
root@ip-10-48-234-13:~# kill -9 1262
root@ip-10-48-234-13:~# kill -9 1265

Step 3. Try to run command again

root@ip-10-48-234-13:~# apt-get install postfix
Reading package lists… Done
Building dependency tree
Reading state information… Done
Suggested packages:
procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin dovecot-common postfix-cdb mail-reader postfix-doc
The following NEW packages will be installed:
postfix
0 upgraded, 1 newly installed, 0 to remove and 72 not upgraded.
Need to get 0 B/1,320 kB of archives.
After this operation, 3,454 kB of additional disk space will be used.
Preconfiguring packages …
(Reading database … 50291 files and directories currently installed.)
Unpacking postfix (from …/postfix_2.9.6-1~12.04.1_amd64.deb) …
Processing triggers for man-db …
Processing triggers for ureadahead …
Processing triggers for ufw …
Setting up postfix (2.9.6-1~12.04.1) …
Adding group `postfix’ (GID 115) …
Done.
Adding system user `postfix’ (UID 108) …
Adding new user `postfix’ (UID 108) with group `postfix’ …
Not creating home directory `/var/spool/postfix’.
Creating /etc/postfix/dynamicmaps.cf
Adding tcp map entry to /etc/postfix/dynamicmaps.cf
Adding sqlite map entry to /etc/postfix/dynamicmaps.cf
Adding group `postdrop’ (GID 116) …
Done.
setting myhostname: ip-10-48-234-13.eu-west-1.compute.internal
setting alias maps
setting alias database
mailname is not a fully qualified domain name. Not changing /etc/mailname.
setting destinations: /etc/mailname, ip-10-48-234-13.eu-west-1.compute.internal, localhost.eu-west-1.compute.internal, localhost
setting relayhost:
setting mynetworks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
setting mailbox_size_limit: 0
setting recipient_delimiter: +
setting inet_interfaces: all
/etc/aliases does not exist, creating it.
WARNING: /etc/aliases exists, but does not have a root alias.Postfix is now set up with a default configuration. If you need to make
changes, edit
/etc/postfix/main.cf (and others) as needed. To view Postfix configuration
values, see postconf(1).After modifying main.cf, be sure to run ‘/etc/init.d/postfix reload’.Running newaliases
* Stopping Postfix Mail Transport Agent postfix [ OK ]
* Starting Postfix Mail Transport Agent postfix [ OK ]
Processing triggers for libc-bin …
ldconfig deferred processing now taking place

That’s it. Thanks for using IThelpblog.com

 

 

One comment to Howto Fix E: Unable to lock directory /var/cache/apt/archives/

  • Ariq Naufal  says:

    Well done..
    You help me, thanks sir

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>