Here is what happens when you install software with apt-get
:
$ sudo apt-get install git htop
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
git-man liberror-perl
Suggested packages:
git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk
gitweb git-arch git-bzr git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
git git-man htop liberror-perl
0 upgraded, 4 newly installed, 0 to remove and 210 not upgraded.
Need to get 3,346 kB/3,414 kB of archives.
After this operation, 21.8 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Asking whether to continue and displaying all this information is useful to know when you're installing new or unfamiliar software but completely unnecessary when you're doing it for the hundredth time.
Adding a -y
or --yes
flag to the command will get rid of the confirmation message:
$ sudo apt-get install git htop -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
git-man liberror-perl
Suggested packages:
git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk
gitweb git-arch git-bzr git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
git git-man htop liberror-perl
0 upgraded, 4 newly installed, 0 to remove and 210 not upgraded.
Need to get 3,346 kB/3,414 kB of archives.
After this operation, 21.8 MB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main liberror-perl all 0.17-1.1 [21.1 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main git-man all 1:1.9.1-1ubuntu0.1 [698 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ trusty-updates/main git amd64 1:1.9.1-1ubuntu0.1 [2,627 kB]
Fetched 3,346 kB in 0s (4,224 kB/s)
Selecting previously unselected package liberror-perl.
(Reading database ... 60994 files and directories currently installed.)
Preparing to unpack .../liberror-perl_0.17-1.1_all.deb ...
Unpacking liberror-perl (0.17-1.1) ...
Selecting previously unselected package git-man.
Preparing to unpack .../git-man_1%3a1.9.1-1ubuntu0.1_all.deb ...
Unpacking git-man (1:1.9.1-1ubuntu0.1) ...
Selecting previously unselected package git.
Preparing to unpack .../git_1%3a1.9.1-1ubuntu0.1_amd64.deb ...
Unpacking git (1:1.9.1-1ubuntu0.1) ...
Selecting previously unselected package htop.
Preparing to unpack .../htop_1.0.2-3_amd64.deb ...
Unpacking htop (1.0.2-3) ...
Processing triggers for man-db (2.6.7.1-1) ...
Processing triggers for mime-support (3.54ubuntu1) ...
Setting up liberror-perl (0.17-1.1) ...
Setting up git-man (1:1.9.1-1ubuntu0.1) ...
Setting up git (1:1.9.1-1ubuntu0.1) ...
Setting up htop (1.0.2-3) ...
But there's still way too much information. Normally you'd only want to know when the installation fails.
Luckily there's a -q
or --quiet
flag:
$ sudo apt-get install git htop -y -q
Reading package lists...
Building dependency tree...
Reading state information...
Suggested packages:
git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk
gitweb git-arch git-bzr git-cvs git-mediawiki git-svn
The following NEW packages will be installed:
git htop
0 upgraded, 2 newly installed, 0 to remove and 210 not upgraded.
Need to get 0 B/2,695 kB of archives.
After this operation, 20.4 MB of additional disk space will be used.
Selecting previously unselected package git.
(Reading database ... 61166 files and directories currently installed.)
Preparing to unpack .../git_1%3a1.9.1-1ubuntu0.1_amd64.deb ...
Unpacking git (1:1.9.1-1ubuntu0.1) ...
Selecting previously unselected package htop.
Preparing to unpack .../htop_1.0.2-3_amd64.deb ...
Unpacking htop (1.0.2-3) ...
Processing triggers for mime-support (3.54ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up git (1:1.9.1-1ubuntu0.1) ...
Setting up htop (1.0.2-3) ...
Better but not good enough.
Let's double the quiet level (which is the maximum) by using the -qq
flag.
When doing that you can omit -y
since -qq
implies it.
$ sudo apt-get install git htop -qq
Selecting previously unselected package git.
(Reading database ... 61166 files and directories currently installed.)
Preparing to unpack .../git_1%3a1.9.1-1ubuntu0.1_amd64.deb ...
Unpacking git (1:1.9.1-1ubuntu0.1) ...
Selecting previously unselected package htop.
Preparing to unpack .../htop_1.0.2-3_amd64.deb ...
Unpacking htop (1.0.2-3) ...
Processing triggers for mime-support (3.54ubuntu1) ...
Processing triggers for man-db (2.6.7.1-1) ...
Setting up git (1:1.9.1-1ubuntu0.1) ...
Setting up htop (1.0.2-3) ...
Wait, what? Even though we asked apt-get
to be quiet it still would not shut up!
That's actually the output of dpkg
(which was forked by apt-get
) not apt-get
itself and that is why we're seeing it.
One quick solution is to pipe the standard output to nothing:
$ sudo apt-get install git htop -qq > /dev/null
And that works. You still see error messages but nothing else.
But that feels like cheating.
Apparently there is an undocumented option to silence dpkg:
$ sudo apt-get -qq -o Dpkg::Use-Pty=0 install git htop
But that doesn't seem to work for me.
-o Dpkg::Use-Pty=0
would be great if it worked because then you could still use -q
and see some useful output
$ sudo apt-get -q -y -o Dpkg::Use-Pty=0 install git htop
Reading package lists...
Building dependency tree...
Reading state information...
Suggested packages:
git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch git-cvs git-mediawiki
git-svn
The following NEW packages will be installed:
git htop
0 upgraded, 2 newly installed, 0 to remove and 2 not upgraded.
Need to get 0 B/2,861 kB of archives.
After this operation, 21.5 MB of additional disk space will be used.
Selecting previously unselected package git.
Copy & pasting apt-get commands
What happens if you copy & paste these two commands in a terminal?
sudo apt-get install -qq git
sudo apt-get install -qq htop
It'll only install git
since only the first line is executed. That's because apt-get
swallows the second line.
You can fix that with &&
sudo apt-get install -qq git && sudo apt-get install -qq htop
or by piping something to stdin
sudo apt-get install -qq git < /dev/null
sudo apt-get install -qq htop < /dev/null
Ultimate apt-get command
Right now I suppose it is
sudo DEBIAN_FRONTEND=noninteractive apt-get install -qq git htop < /dev/null > /dev/null
No password for sudo
Add yourself to the sudoers
list so that you don't have to enter your password over and over again:
echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee -a /etc/sudoers