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 '15 at 11:17
  • What do you mean notify?
    – Camandros
    Nov 12 '15 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 '15 at 12:32
  • 1
    apt-get has no built-in functionality for this purpose.
    – muru
    Nov 12 '15 at 13:50

Probably, not until Debian bug #754103 is resolved:

apt: support option to wait for lockfile

Reported by: Michael Prokop

Date: Mon, 7 Jul 2014 15:06:01 UTC

Severity: wishlist

Found in version apt/1.0.5

  • 1
    It is fixed in apt version 1.9.11, newer of which is available e.g. in Ubuntu 20.04.
    – jarno
    May 14 '20 at 22:06
  • 1
    Note that only apt has this feature, not apt-get.
    – jarno
    May 15 '20 at 5:57

(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 '18 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?
    – vinzee
    Nov 18 '19 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.