How to install software packages in non-interactive batch mode on Debian/Ubuntu

If you are a system admin, at some point you may have wondered how to install a list of software packages in one shot. Manually installing software programs on multiple Linux systems would be a tedious job, and your time can be better spent elsewhere. If you seek to install multiple packages in non-interactive batch mode, you can check out this guideline. This is for Debian/Ubuntu systems.

Advanced Packaging Tool (APT) is a Debian way of managing software packages. APT handles installation, removal and update of software packages, as well as automatically resolves problems of inter-package dependencies. As such, APT is ideal for non-interactive package installation.

If you have a text file containing a list of software packages to install, you can bulk install all the packages in one shot as follows.

$ sudo apt-get install -y `cat package.txt | tr "\n" " "`

In the above, I assume that package.txt contains a list of package names (one package name in each row). The "-y" option forces "yes" for every confirmation dialog during installation, and thus is necessary in non-interactive batch mode.

While "apt-get install" command can easily override any confirmation prompt with "-y" option, "apt-get upgrade" that can pop-up various screens for configuration and warnings may not work. For example, when you upgrade your kernel using "apt-get", you cannot circumvent a pop-up screen warning of reboot. In order to get around such pop-up configuration screens as well, there are two ways to do it.

In order to force non-interactive mode in apt-get system-wide, you can use reconfigure debconf as follows.

$ sudo dpkg-reconfigure debconf

In the subsequent package configuration screen, choose "noninteractive" interface. Then you won't be asked any question while using apt-get.

If you think that such system-wide change is too risky, you can set DEBIAN_FRONTEND environment variable to enter a temporary batch mode as follows.

$ sudo DEBIAN_FRONTEND=noninteractive apt-get install `cat package.txt | tr "\n" " "`

Then non-interactive batch mode will be applied to a single invocation of "apt-get install".

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of Xmodulo.com. He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.
Your name can also be listed here. Write for us as a freelancer.

One thought on “How to install software packages in non-interactive batch mode on Debian/Ubuntu

  1. I guess here we can also use SMT (Subscription Management Tool) to install multiple packages in non-interactive mode.
    For this, first we have to configure SMT server, and then on that server we have to download all the packages, so later on we will install these packages in one shot in non-interactive mode environment. Because of that there is no need to install these packages manually on each system as we can install it centrally on all the remaining servers/systems by simply connecting these systems to SMT server directly.

Leave a comment

Your email address will not be published. Required fields are marked *

Current ye@r *