109

I am trying to write a bash script to install a list of software. I am using --assume-yes to get past the prompts.

This following line somehow doesn't work:

sudo apt-get install python-software-properties --assume-yes

If I try to apt-get without --assume-yes it works but the prompt asks me to:

please [Enter] to continue or ctrl+c to cancel adding it

How do I add Enter as a command when running apt-get install instead of using --assume-yes?

2

3 Answers 3

142

Your problem is that the option should be before the packages, not after, this is the correct syntax:

apt-get <options> command package=version/release

So, for it to work it should be:

sudo apt-get --assume-yes install python-software-properties

apt-get is forgiving when mixing up command and options, but to err on the safe side, you should always use the options before the command and never put options or commands after the name of the package.

75

Add -y flag to apt-get install <package-name> command like below, you won't get any prompt while installing packages.

sudo apt-get install -y <package-name>

From apt-get --help

-y  Assume Yes to all queries and do not prompt
4
  • 6
    @PeterMortensen they do the same thing. From the man page:-y, --yes, --assume-yes Automatic yes to prompts
    – davejagoda
    Dec 6, 2017 at 18:59
  • 3
    Note that this may not be enough and you may also need to add -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" to your commands. See raphaelhertzog.com/2010/09/21/… for details.
    – TTimo
    Oct 10, 2019 at 15:45
  • @TTimo Wow! 6 days after you posted that comment, I come along and find that's exactly the answer I needed!! If I could upvote your comment more I would!
    – ckhatton
    Oct 16, 2019 at 7:00
  • Feel free to edit the answer with additional options. Oct 16, 2019 at 7:09
7

For another silent and effective way as follows :

sudo DEBIAN_FRONTEND=noninteractive apt-get install -qq python-software-properties < /dev/null > /dev/null

You must log in to answer this question.

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