I want to install libpq-dev on my Vagrant machine. I install it with

$ apt-get install -y libpq-dev

During installation a prompt appears which asks if it's allowed to restart some services automatically. This prompt breaks my Vagrant provision. How can disable this prompt?



There are services installed on your system which need to be restarted when certain libraries, such as libpam, libc, and libssl, are upgraded. Since these restarts may cause interruptions of service for the system, you will normally be prompted on each upgrade for the list of services you wish to restart. You can choose this option to avoid being prompted; instead, all necessary restarts will be done for you automatically so you can avoid being asked questions on each library upgrade.

****EDIT ****

Thanks to Patrick's answer and this question I fixed it. Now my Vagrantfile contains:

 sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libpq-dev
  • I was suggesting to use -y but seems it doesn't change much. see man apt-get | less +/--force-yes Jul 24, 2014 at 8:25
  • I've tried that optiont too, but that didn't worked either.
    – OrangeTux
    Jul 24, 2014 at 8:44
  • Maybe a bit late, but -y is an option for apt-get, but the prompt in question comes from dpkg, the package management backend used by apt. DEBIAN_FRONTEND is read by dpkg, that's why it works in this case and -y does not. Sep 25, 2020 at 10:26

4 Answers 4


Set the environment variable DEBIAN_FRONTEND=noninteractive.

For example:

export DEBIAN_FRONTEND=noninteractive
apt-get install -y libpq-dev

This will make apt-get select the default options.

  • 2
    Doesn't work in this case. Jul 8, 2019 at 14:42
  • 3
    Please specify what "this case" is. The author of the question has selected this answer as correct. If the answer does not work for you, I recommend you ask a new question and make sure to clarify how your case is different, and that this does not work for you.
    – phemmer
    Jul 8, 2019 at 18:28
  • 1
    It didn't work for me neither.
    – Felipe
    Jul 10, 2019 at 1:40
  • Is the default option to restart the service or not restart the service?
    – Nicholi
    Oct 25, 2019 at 22:33
  • 5
    @RSHAP that's because you have exported the DEBIAN_FRONTEND variable in your shell, but the executed the commands with sudo. This answer describes running the commands as root. When using sudo you will need to prefix each command with the environment variable, instead of exporting it, e.g. sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libssl-dev openssl
    – spikyjt
    Apr 1, 2020 at 7:45

You should be able to achieve this using debconf-set-selections. From the man page:

debconf-set-selections can be used to pre-seed the debconf database
with answers, or to change answers in the database. Each question will
be marked as seen to prevent debconf from asking the question

In order to determine the required input to debconf-set-selections if unknown, you can answer the prompt manually and then inspect the debconf database to find the correct value. To do this, install debconf-utils:

sudo apt-get -y install debconf-utils

which provides the debconf-get-selections command. Then:

sudo debconf-get-selections | grep libssl1.0.0:amd64

to check the values in the database. On my system (Ubuntu, but Debian should be similar) I am not prompted when I apt-get install libpq-dev, and I have this entry:

libssl1.0.0:amd64   libssl1.0.0/restart-services     string

so you should be able to use:

echo 'libssl1.0.0:amd64 libssl1.0.0/restart-services string' | sudo debconf-set-selections

to set the list of services to restart when upgrading libssl to 'none'.

Under Debian, there should be more information about valid values for this line in the questions.dat file under /var/lib/cdebconf. See https://www.debian.org/releases/stable/i386/apbs03.html.en for more details.


I think the existing answers may be a bit old. The following worked for me recently.

To see the settings for a package

sudo debconf-show <package-name>


$ sudo debconf-show libssl1.1 
* libraries/restart-without-asking: false

To change the setting

echo '<package-and-setting-string>' | sudo debconf-set-selections


echo 'libssl1.1 libraries/restart-without-asking boolean true' | sudo debconf-set-selections

Bonus tip, to set this setting for all packages use '*' in place of the package name.


echo '* libraries/restart-without-asking boolean true' | sudo debconf-set-selections
  • 2
    The accepted answer did not work for me but using debconf-set-selections did.
    – bradj
    Nov 28, 2019 at 2:12

You can disable this feature on Debian 11 by uninstalling the needrestart package.

apt remove needrestart

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.