34

Just for curiosity, sometimes while installing software throught apt-get install software_name the terminal prompt me for a confirmation "type Yes or No", but not allways.

I dont mean the sudo password prompt, but the message "Will be downloaded and configrated XXX Kb, continue?" (or something similar)

Why?

1
  • 2
    Essentially, if packages other than those mentioned in the arguments need to be installed, it will ask.
    – muru
    Mar 19, 2015 at 18:51

3 Answers 3

26

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.

3
  • i thought the same motivations.. but i want to be secure of the answer
    – Strae
    Aug 23, 2010 at 7:41
  • Yes, this answer is correct. I'll add that you can (useful if you're trying to automate something) use the -y flag if you don't want to be prompted.
    – Umang
    Aug 24, 2010 at 12:47
  • @Umang: thanks for the hint, but i dont need to automate anything at the moment, was just a curiosity ;)
    – Strae
    Aug 25, 2010 at 14:38
14

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...

2
  • But is there a way of getting it to ask you every time? Even by changing the actual code of the program.
    – user364819
    Mar 19, 2015 at 18:53
  • @Toroidal changing the program's code is a little bit outside the scope here - you might have to dig into apt or apt-get's manpages to figure out how to change preferences, as it's possible there's already a setting you can change to force it.
    – Thomas Ward
    Mar 19, 2015 at 18:58
10

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
1
  • Or, to get aptitude to prompt on a specific run, use aptitude -P. May 10, 2015 at 15:26

You must log in to answer this question.

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