96

I always see commands like this

apt-get -y install 

What is the -y tag for and what is the difference between apt-get install with and without the -y tag?

118

From the results of running man apt-get

-y, --yes, --assume-yes
           Automatic yes to prompts; assume "yes" as answer to all prompts and
           run non-interactively. If an undesirable situation, such as
           changing a held package, trying to install a unauthenticated
           package or removing an essential package occurs then apt-get will
           abort. Configuration Item: APT::Get::Assume-Yes.  

If you run an apt-get command without the -y option, you need to answer to all prompts that you get from that command interactively in order for the execution of the command to continue.

  • perfect answer =) +1 – A.B. Sep 11 '15 at 11:58
  • 3
    Also note that this is a common switch in utilities that have confirmation prompts in their functionality. While it's convenient in the shell, the real purpose is for automating scripts. – user1359 Sep 11 '15 at 14:51
  • 2
    I wouldn't go as far as calling -y "common". The feature is fairly common in system administration tools (of which apt-get is one) but the method varies. When in doubt, always refer to the man page for the command in question for what parameter to use and what effect it has. – a CVn Sep 11 '15 at 15:39
  • 5
    One side effect of using -y is that it will skip downgrades, whereas if the user entered y, it would perform the downgrades. So if you want -y to execute the same thing as a user entering y, you also need to add --allow-downgrades. – wisbucky Mar 24 '18 at 0:00
  • 1
    I don't know why @wisbucky 's comment doesn't have more upvotes. Very important to know, thanks – frank Jun 27 '18 at 21:59

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.