How can I install apt packages non-interactively?

If I run:

sudo apt-get --yes install postfix 

or

sudo bash -c 'yes | apt-get --yes install postfix'

an interactive prompt appears to configure postfix. I need to automate the installation of postfix (I can modify the configuration files after the install).

Is there some magic that lets me install postfix (and other package) without human intervention?

1 Answer

Set the DEBIAN_FRONTEND to noninteractive:

DEBIAN_FRONTEND=noninteractive apt-get ...

This is also applicable to dpkg --reconfigure, dpkg-configure, etc.

From man 7 debconf:

noninteractive This is the anti-frontend. It never interacts with you at all, and makes the default answers be used for all questions. It might mail error messages to root, but that's it; otherwise it is completely silent and unobtrusive, a perfect frontend for automatic installs. If you are using this front-end, and require non-default answers to questions, you will need to preseed the debconf database; see the section below on Unattended Package Installation for more details.

If you do set noninteractive, you should consider answering debconf questions by using debconf-set-selections.

5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like