LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-30-2011, 12:56 PM   #1
armandino
Member
 
Registered: Oct 2005
Posts: 72

Rep: Reputation: 15
Apt-get install does not ask for confirmation


In my latest Debian I noticed that apt-get install does not, as I expected, stop to ask for confirmation before starting the actual download/install process.

After the usual messages:
Code:
Reading...
...
Building...
...
x upgraded, y newly installed, z to remove and 0 not upgraded.
Need to get N.0MB of archives.
it directly carries on with the operation, which is obviously very annoying when, as I usually do, you first want to see what packages are needed (and how heavy the download) and then you want to decide whether to proceed or not.

The man pages, as I correctly remembered, talk about a -y option intended to bypass confirmation requests, which means that the default behaviour should be the opposite.
I tried also on a Ubuntu 10.10 with the same result.

Am I missing something?
Is the -y option pre-configured somewhere?
How can I get "normal" behaviour?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 01-30-2011, 01:14 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
If what you asked for on the command line is exactly what you will get, no confirmation is asked for. If additional things will happen, it is asked for. Example below. In the first, I didn't ask for anything specific. In the second, what I asked for is exactly what I would get.
Code:
$ sudo aptitude upgrade
W: The "upgrade" command is deprecated; use "safe-upgrade" instead.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Reading task descriptions... Done
The following packages will be upgraded:
  linux-libc-dev
1 packages upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
Need to get 0B/770kB of archives. After unpacking 12.3kB will be used.
Do you want to continue? [Y/n/?] 
# etc
$ sudo aptitude install libwww-curl-perl
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Reading task descriptions... Done
The following NEW packages will be installed:
  libwww-curl-perl
0 packages upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 53.0kB of archives. After unpacking 225kB will be used.
Writing extended state information... Done
# etc
If your apt(itude) is not prompting you for complex operations, perhaps you have made -y the default in /etc/apt/preferences.

Last edited by AlucardZero; 01-30-2011 at 01:16 PM.
 
Old 01-31-2011, 12:12 AM   #3
armandino
Member
 
Registered: Oct 2005
Posts: 72

Original Poster
Rep: Reputation: 15
Thanks for your help.

My question then changes. Is it possible to have apt-get always ask for confirmation before starting the actual operation?

Alternatively, is there another way to know, without installing, how many files should be downloaded and so on? In other words, what can I do when I just want to know the information that apt-get displays just before asking (when it does) for confirmation?
 
Old 01-31-2011, 12:20 AM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
There may b another option, but I always use a "-s" before installing anything.

The -s option (or longer versions --simulate, --dry-run, and others) tell apt-get to display what it would do if it were to perform the operation.

So, building on AlucardZero's example:
Code:
$ sudo apt-get -s install libwww-curl-perl
[sudo] password for darkhelmet:
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  libcurl4-gnutls-dev
The following NEW packages will be installed:
  libwww-curl-perl
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Inst libwww-curl-perl (4.11-1 Ubuntu:10.04/lucid)
Conf libwww-curl-perl (4.11-1 Ubuntu:10.04/lucid)
$ 
 
Old 01-31-2011, 01:55 AM   #5
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Continuing on Dark_Helmet's logic, you could work out (a script or) something to have your apt run a dry-run, then confirmation, then "real-run", instead of the default route. For example, something simple like this might help you out (wrapped so that you only have to run one command):
Code:
apt-get --dry-run upgrade
echo "Now would be a good time to cancel, if needed..."
read answer
apt-get upgrade
That would first run the dry-run, showing what would happen, then throw the message at you and wait for input. Hitting Enter would then proceed with the real thing, or ^C (or equivalent) cancel the thing.

Edit: you'd want to wrap it up so that when you type apt-get something on the command line, it's not apt-get you really call but a wrapper that picks up the argument(s), then does what is described above (with those arguments, so that you can do other things than just upgrade if you need to).

Last edited by b0uncer; 01-31-2011 at 01:56 AM.
 
Old 01-31-2011, 11:34 AM   #6
armandino
Member
 
Registered: Oct 2005
Posts: 72

Original Poster
Rep: Reputation: 15
Thanks everybody.

I knew about the -s option, but I really thought (and hoped) I was missing something obvious.
I know Debian tends to assume that users are well aware of what they are doing (for example, it does not hide the root account while many others do), but I think a confirmation request would be very useful even to a system administrator. When you... precisely issue "apt-get install package_name" you may not know that the package requires loads of other stuff, which gets installed straight away.

Besides, the same "problem" affects also Ubuntu, which on the contrary is tailored for far less experienced users.

Anyway, I'll learn to always use "apt-get -s" or, if I get hit by an attack of good will :], I'll even work out those suggested little scripts...
 
Old 01-31-2011, 03:20 PM   #7
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Not trying to beat a dead horse, I promise, but just for clarity...

Quote:
Originally Posted by armandino
When you... precisely issue "apt-get install package_name" you may not know that the package requires loads of other stuff, which gets installed straight away.
What AlucardZero was touching on is that apt-get will not ask confirmation if "package_name" is the only thing to install. As given in the original example, libwww-curl-perl installs only one item: itself.

Let me come up with an example to illustrate. Say I want to install "package." Let's also say package has two dependencies: depend1 and depend2. Let's also say that depend1 and depend2 have no dependencies of their own. Here's a list of commands and whether or not they ask for confirmation:
Code:
# apt-get install package
confirmation asked: would auto-install depend1 and depend2

# apt-get install package depend1
confirmation asked: would auto-install depend2

# apt-get install package depend1 depend2
no confirmation: there are no dependencies to install that were not listed on the commandline

# apt-get install depend1
no confirmation: there are no dependencies to install
So, if installation requires installing a package not specified on the command line, apt-get will ask for confirmation. If every package (including dependencies) is provided on the command line, then no confirmation is asked.

For people with the opposite problem (wanting to avoid confirmation), specifying all dependencies on the command line is a bad idea. By doing so, you have manually installed the dependencies. Apt-get will not mark manually installed dependencies for autoremoval if you apt-get remove the package that depends on them.
 
2 members found this post helpful.
Old 02-02-2011, 01:18 PM   #8
armandino
Member
 
Registered: Oct 2005
Posts: 72

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Dark_Helmet
...So, if installation requires installing a package not specified on the command line, apt-get will ask for confirmation. If every package (including dependencies) is provided on the command line, then no confirmation is asked...
Thanks a lot. Very useful and clear.
One last question remains. What command should I issue if I want to know, before installing, the weight (download) of a single package with no dependencies (when apt-get does not ask for confirmation)?

Last edited by armandino; 02-02-2011 at 01:27 PM.
 
Old 02-02-2011, 02:03 PM   #9
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
I looked through the apt-get man page and a safe option is "--print-uris". You can run it as an unprivileged user, and it will display other information that you might find interesting. In addition to the specific --print-uris output, it displays the normal install header information. Specifically the download size and the installation size:
Code:
$ apt-get --print-uris install libwww-curl-perl
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Suggested packages:
  libcurl4-gnutls-dev
The following NEW packages will be installed:
  libwww-curl-perl
0 upgraded, 1 newly installed, 0 to remove and 9 not upgraded.
Need to get 61.7kB of archives.
After this operation, 238kB of additional disk space will be used.
'http://mirrors.pavlovmedia.net/ubuntu/pool/universe/libw/libwww-curl-perl/libwww-curl-perl_4.11-1_i386.deb' libwww-curl-perl_4.11-1_i386.deb 61654 SHA256:39d98bd56e1a1426eb8cf7c6361e424c78f271f1420bcb3a9804eab7ef5da42f
Here's a simple one-liner to show the download size and the install size:
Code:
$ apt-get -y --print-uris install libwww-curl-perl | sed -n -e 's/Need to get \(.*\) of archives./\1/p' -e 's/After this operation, \(.*\) of additional disk space will be used./\1/p'
61.7kB
238kB
NOTE: I added the -y option to the above command in case anyone tries to convert that command into an alias. Without the -y, the user must be certain that no other dependencies are necessary. If there is an unexpected dependency, the command appears to hang because it's waiting for a y/n confirmation (and all of its output is redirected into sed).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there knoppix-like distro, that we can: apt-get update; apt-get install programs ? frenchn00b Linux - Distributions 7 04-28-2008 02:06 PM
LXer: Apt-get remove SUSE; apt-get install Etch LXer Syndicated Linux News 0 05-26-2007 07:46 PM
Question about 'apt-get upgrade' versus 'apt-get install' eur0dad Red Hat 8 07-16-2006 05:41 PM
(Pre Install) Partition Size Confirmation ? Grongle Slackware 6 05-13-2006 09:52 AM
knoppix 3.4 and no apt-setup how to fix info install apt-file + base-config maximalred Debian 0 10-16-2004 06:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 07:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration