Why `sudo apt-get install XXXX` sometimes request confirmation, others not?

It will usually ask you if there are suggested or recommended packages that depend on the software you are attempting to install, It might also depend on the size of the program or security of the repository you are downloading from.


apt-get install new-package will ask for confirmation only if it also installs dependencies of the given package.

If just the single package you specified is going to be installed without any additional stuff, it stays quiet as you already "confirmed" you want to have that one by typing it.
But if there are some dependency packages, you might change your mind and want to stop the installation (e.g. because one of them caused trouble before), so it prompts you for the y/n.

Now if you want to see what it will do, you can do a dry-run/simulation of the install command. You set this switch by adding an -s to the arguments. Example: Installation of the single package sudoku

bytecommander@AlkaliMetal:~$ sudo apt-get install sudoku -s
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  sudoku
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Inst sudoku (1.0.1-5 Ubuntu:14.10/utopic [i386])
Conf sudoku (1.0.1-5 Ubuntu:14.10/utopic [i386])

That shows you what will happen, but not how big the downloads will be, as the confirmation prompt would do.

Therefore, another switch may be used, --print-uris. The same example:

bytecommander@AlkaliMetal:~$ sudo apt-get install sudoku --print-uris
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  sudoku
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 28.4 kB of archives.
After this operation, 106 kB of additional disk space will be used.
'http://ftp.uni-stuttgart.de/ubuntu/pool/universe/s/sudoku/sudoku_1.0.1-5_i386.deb' sudoku_1.0.1-5_i386.deb 28426 MD5Sum:ecd0e3cd4fc1e4e4edfe6c59d1c54847

The --print-uris switch will not only block the actual install, but show the downloaded and installed sizes and additional information about the package (web address and MD5Sum).
Attention: Don't use --print-uris and -s together. It will look like -s only.
Note also that you should add the -y switch (= assume yes to every question) if you want to process the output, because this one will prompt you for confirmation following the same rules as normal install without switches.


Now if you want to filter out the download and installed file size information only without having to read through all the other things, you can use the following command to achieve this (thanks to @terdon for assisting). Again with the example sudoku:

bytecommander@AlkaliMetal:~$ LANG=C sudo apt-get -y --print-uris install sudoku | grep -Po '^(Need to|After this).*?\K[0-9.]+[ a-zA-Z]+? '
28.4 kB
106 kB

You see that the first line of the output is the download size and the second line describes the space needed for the installation.

Because this command is not easy to type and even harder to remember, copy the following into a script file e.g. called apt-get-install-checker.sh:

#! /bin/bash

LANG=C sudo apt-get install -y --print-uris $* |
grep -Po '^(Need to|After this).*?\K[0-9.]+[ a-zA-Z]+? ' |
sed '1,1s/^/Download size: /;2,2s/^/Installed size: /'

Don't forget to chmod +x apt-install-checker.sh before you execute it!

Example output:

bytecommander@AlkaliMetal:~/bin$ ./apt-install-checker.sh sudoku
Download size: 28.4 kB 
Installed size: 106 kB 

Script still in development! Planned features: It should ask you whether you want to perform the install and then continue and run it. Maybe some other nice gadgets that come into my mind tomorrow...


From what I understand apt-get asks for confirmation only when there are additional dependencies to install. There is no way to force confirmation by default for all packages.

However, it is possible to force confirmation on any install command when using aptitude.

echo 'Aptitude::CmdLine::Always-Prompt "true";' | sudo tee -a /etc/apt/apt.conf.d/05aptitude