I'm provisioning a vagrantbox with a small script running few steps.
Most are performing apt-get -y -qq install and update

config.vm.provision "shell", privileged: false, inline: <<-SHELL
   sh 050_Certificats.sh
   sh 070_Utilitaires.sh
   sh 100_JDK.sh "17"
   sh 150_Postgresql-Postgis.sh "15" "3"
   sh 200_NodeJS-Angular.sh "16"
   sh 250_ELK.sh "7.x"
   sh 300_Kafka.sh "3.4.0" "2.12"
   sh 350_Geoserver.sh "2.23.1"
echo "050 : Installation des certificats et mise à jour"

sudo apt-get -y -qq install gnupg2 wget ca-certificates
sudo apt-get -y -qq update

But the apt-get -y -qq install statements aren't silent on the output (apt-get -y -qq update are...). And I would like to avoid the need of terminating my statements by > /dev/null:

==> default: Running provisioner: shell...
    default: Running: inline script
    default: 050 : Installation des certificats et mise à jour
    default: dpkg-preconfigure: unable to re-open stdin: No such file or directory
    default: Selecting previously unselected package gnupg2.
    default: (Reading database ... 
(Reading database ... 65%abase ... 5%
    default: (Reading database ... 70%
    default: (Reading database ... 75%
    default: (Reading database ... 80%
    default: (Reading database ... 85%
    default: (Reading database ... 90%
    default: (Reading database ... 95%
(Reading database ... 68876 files and directories currently installed.)
    default: Preparing to unpack .../gnupg2_2.2.27-2+deb11u2_all.deb ...
    default: Unpacking gnupg2 (2.2.27-2+deb11u2) ...
    default: Setting up gnupg2 (2.2.27-2+deb11u2) ...
    default: Processing triggers for man-db (2.9.4-2) ...
  • Do you require any of the reported lines, and how do you differentiate the two groups? Why not merely redirect the whole of stdout and stderr to a log file at the outermost level (for possible later reference). May 28, 2023 at 7:49

1 Answer 1


-q controls apt-get’s output, but there are many other programs involved in package installation, all of which can produce output: dpkg itself, maintainer scripts etc.

You can reduce the amount of output produced by dpkg by disabling its progress information:

sudo apt-get -y -qq install -o Dpkg::Progress-Fancy="0" -o APT::Color="0" -o Dpkg::Use-Pty="0" ...

See log output of apt-get in shell for details.

Incidentally, you should run apt-get update before trying to install or upgrade anything.

  • Thanks! The apt-get update after apt-get install is to refresh certificates. May 29, 2023 at 4:29
  • update only refreshes the local copies of repository package lists (and related information), none of that is affected by certificates. Anyway, since this is the first script run while provisioning your VM, you should run update before install to ensure that the local repository information is up-to-date. May 29, 2023 at 6:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .