Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

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.

share|improve this answer
    
What if there is a configuration screen without a y/n answer? –  djeikyb Jan 26 '12 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). –  Bruno Pereira Jan 26 '12 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 '12 at 1:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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