If you are running apt-get commands on terminal and want to install stuff on the software center, the center says it waits until apt-get finishes. I wanted to know if it is possible to do the same but on the terminal, i.e., make apt-get on the terminal wait until the lock is released.

I found this link, that uses aptdcon to install stuff. I would like to know if:

  • Is it really not possible to do with apt-get?
  • Is aptdcon compatible with apt-get, i.e., can I use both to install stuff without borking the system?
  • does apt-get not notify you if you operate in the software center?
    – blissini
    Nov 12, 2015 at 11:17
  • What do you mean notify?
    – Camandros
    Nov 12, 2015 at 11:27
  • if you run apt-get <some command> in the terminal, it will tell you that a different process is locking the package database (e.g. the software center is operating). So the system should already behave like you want it.
    – blissini
    Nov 12, 2015 at 12:32
  • 1
    apt-get has no built-in functionality for this purpose.
    – muru
    Nov 12, 2015 at 13:50
  • You should consider choosing this answer unix.stackexchange.com/a/277255/3285 as it's fixed now. Apr 22, 2022 at 18:37

3 Answers 3


apt 1.9.11

This was solved in Debian bug #754103 in this commit. The fix is in versions of apt newer than 1.9.11.

  • apt(8): Wait for lock (Closes: #754103)

You can enable this option by setting -o DPkg::Lock::Timeout=60 as an argument to apt or apt-get. Where 60 is the time to wait in seconds for the lock.

apt -o DPkg::Lock::Timeout=60 install FOO
apt-get -o DPkg::Lock::Timeout=60 install FOO

You can test this by running two identical commands and simply not answering immediately on the first one to Do you want to continue? [Y/n]? On the second command you run, it'll tell you,

Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process 946299 (apt)

  • 1
    It is fixed in apt version 1.9.11, newer of which is available e.g. in Ubuntu 20.04.
    – jarno
    May 14, 2020 at 22:06
  • 1
    Note that only apt has this feature, not apt-get.
    – jarno
    May 15, 2020 at 5:57
  • 1
    I've updated this answer to reflect the comment by @jarno and the ticket you linked. Apr 22, 2022 at 18:36

(Repasting from Ask ubuntu)

There is now an option built into apt-get that lets you wait for the other apt to finish.

Use the DPkg::Lock::Timeout option to set a timeout, in seconds, for an apt-get command. This example will wait for 60 seconds:

sudo apt-get -o DPkg::Lock::Timeout=60 install packagename

If you set that value to -1, it will keep waiting forever.

sudo apt-get -o DPkg::Lock::Timeout=-1 install packagename

For more information see: Waiting for apt locks without the hacky bash scripts. This option was added to apt-get in Feb 2020.


you can do this already:

create a new script called apt-get (wrapper for apt-get) in the


directory with the following bash code inside:

#Make sure there is no space before the hashbang above!
tput sc 
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
     case $(($i % 4)) in
         0 ) j="-" ;;
         1 ) j="\\" ;;
         2 ) j="|" ;;
         3 ) j="/" ;;
     tput rc
     echo -en "\r[$j] Waiting for other software managers to finish..." 
     sleep 0.5
/usr/bin/apt-get "$@"

Don't forget to make it executable:

sudo chmod +x /usr/local/sbin/apt-get

run it. run it again with synaptic or another apt-get open. ;)

/usr/local/sbin comes earlier in the path...

I think it could cause chaos with scripts somewhere... maybe?

  • 2
    Should probably acknowledge the author: askubuntu.com/questions/132059/…
    – adeelx
    Oct 4, 2018 at 17:44
  • It did not work in my case.. I got: [/] Waiting for other software managers to finish...E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
    – vvvvv
    Nov 18, 2019 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.