203

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?

muru
  • 207,970

1 Answers1

235

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.

karel
  • 122,695
  • 134
  • 305
  • 337
  • 5
    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
  • 4
    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. – user Sep 11 '15 at 15:39
  • 15
    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 00:00
  • 1
    I just started using a Raspberry Pi 3 I bought, and encountered sudo apt update && sudo apt upgrade -y in the process of following an online tutorial. In doing my due diligence to understand the command they were having me enter, I tried checking "man apt upgrade" but it didn't explain the -y switch so I googled and ended up here. Any idea why the man page didn't explain? I'm guessing it was either because I was asking the system about an alias, or because it's assumed I'm familiar with purportedly "common" switches. Either way, thank you for covering the gap with your answer! – Twisted- on strike - Check bio Apr 12 '24 at 15:09
  • @Twisted-onstrike-Checkbio If you want to read about here's how to find it fast. First type man apt-get to show the man pages for apt-get. Then type /-y and press Enter to search for the -y option description. It's as easy as Pi! – karel Apr 12 '24 at 15:48
  • apt is different from apt-get (although very similar so they are often conflated) & is in fact apt-get's successor. In apt's man page, you see section headers like upgrade (apt-get(8)), which tells you that there's more info in apt-get manual section 8, eg $ man 8 apt-get. – AFOC Jun 02 '25 at 04:44