1

TL/DR: I think the accepted answer is a complete one to my expectation. Other answers that add useful info to the topic are still welcome.

I have used both rpm(dnf) and apt package management systems. In rpm systems I notice when I update or install new packages it almost always prompts the user for confirmation and the default is "no" most of the time. In the apt system I notice that sometimes it does not prompt for the user confirmation and sometimes prompts the user with a default "yes".

So my question is, when does apt-get or things alike prompt the user for confirmation, and if it does so, when does it defaults to yes?

I think I should be able to find the answer if I dig through the source of apt but I have failed to do it, probably because I haven't used the right tool or the right method for processing the source code.

Note that I am not asking for apt-get -y, apt-get --assume-no or things alike. I know these options and I am not asking for someone to tell me that they exist. I am asking the behavior when no additional command line flags are provided. It may depend on command line options when compiling, but answering the behavior for the apt shipped in the default debian and ubuntu repos should be enough.

Edit: I know there is Apt-get install does not ask for confirmation on LinuxQuestions.org, but I have always thought that there are cases where the prompt of apt-get defaults to no (i.e. [y/N]), and I want evidence from the source.

From the accepted answer, it is clear that

If the prompt is in the form

Do you want to continue? [Y/n]

It always defaults to yes.

From the comment in the accepted answer I finally found evidence from the source code that I have been looking for: https://github.com/Debian/apt/search?utf8=%E2%9C%93&q=YnPrompt

So I think I have found a complete answer to my question.

Edit 2: I realized not long after I accepted the answer, that I actually saw the [y/N] on yum-based systems.

2

apt-get upgrade will always prompt.

apt-get install will only install automatically if there are no conflicts, held packages and all of the new packages to be installed were explicitly specified. That is if it brings in dependencies automatically it will prompt.

  • So if apt-get install prompts, when does it default to yes (i.e. [Y/n]) and when does it default to no (i.e. [y/N])? – Weijun Zhou Jan 4 '18 at 3:01
  • It doesn't. Either it prompts or it doesn't prompt. If you're talking about where --assume-yes will fail thats a different question isn't it? – jdwolf Jan 4 '18 at 3:06
  • I mean, "Do you want to continue? [Y/n]" vs. "Do you want to continue?[y/N]" I have seen both cases if I remember correctly. – Weijun Zhou Jan 4 '18 at 3:12
  • That particular prompt will always be "Y/n" so if you press enter it assumes yes. – jdwolf Jan 4 '18 at 3:27
  • Thank you. Then maybe I have some confusion here, with the rpm system. I will mark the answer accepted. – Weijun Zhou Jan 4 '18 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.