1

Can I skip the questions asked during install in terminal?

I was writing sudo apt-get update && sudo apt-get upgrade && sudo shutdown -h 1 so that the computer shuts down after updating. But I was wondering what if questions popup during updating like 256 MB updates y/n?

1 Answer 1

2

Adding -y to sudo apt-get upgrade will make it assume yes to all queries.

From the man page:

-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.

So if you make your command look like this

sudo apt-get update && sudo apt-get upgrade -y && sudo shutdown -h 1

To run without risk of new password prompt before shutdown do this

sudo sh -c "apt-get update && apt-get upgrade -y && shutdown -h 1"

it will run and "answer" yes to any prompts you have during sudo apt-get upgrade.

For more information on the command apt-get type in a terminal man apt-get.

3
  • 2
    What if there is a configuration screen without a y/n answer?
    – djeikyb
    Jan 26, 2012 at 23:45
  • If it's a fault the command chain will break and the last && will never be executed, the computer will not shutdown. I dont think there is a argument that ignores faults (that would also defect the purpose of the script since no updates would be installed on fault). Jan 26, 2012 at 23:47
  • Depending on the time taken by apt-get upgrade, sudo shutdown may require the password to be entered again. If you want shutdown to run regardless of the exit status of the upgrade replace the last && with ;. sudo sh -c "apt-get update && apt-get upgrade -y && shutdown -h 1" should help with the password problem of a long upgrade.
    – Zoke
    Jan 27, 2012 at 1:41

You must log in to answer this question.

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