Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force no prompt in apt-get upgrade or apt-get dist-upgrade

I'm using AWS EC2 14.04 LTS and I'm trying to run command apt-get -y upgrade or apt-get -y dist-upgrade, however, I always get prompt like this:

enter image description here I tried following commands and none of them work and I still get above prompt:

apt-get update && apt-get -y -o Dpkg::Options::="--force-confmiss" -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" dist-upgrade

apt-get update && apt-get -o Dpkg::Options::='--force-confold' --force-yes -fuy dist-upgrade

I have been been googling for solutions but could not find that actually works. Anyone has any thought?

Thanks

like image 353
Nam Nguyen Avatar asked Jul 24 '14 06:07

Nam Nguyen


1 Answers

Took me a while to figure out the simple solution. I could avoid the prompt by adding DEBIAN_FRONTEND='noninteractive' apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'

So here is my common function that I use to upgrade all my Ubuntu machines:

function runAptGetUpgrade()
{
    DEBIAN_FRONTEND='noninteractive' apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' upgrade
    DEBIAN_FRONTEND='noninteractive' apt-get -y -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' dist-upgrade

    apt-get autoremove -y
    apt-get clean
    apt-get autoclean
}

REF My Lib: https://github.com/gdbtek/ubuntu-cookbooks/blob/master/libraries/util.bash

REF Answer: https://serverfault.com/questions/479571/running-apt-get-upgrade-with-chef-solo

like image 187
Nam Nguyen Avatar answered Sep 22 '22 06:09

Nam Nguyen