In order avoid typing out all of the apt-get commands when updating my computer I have made a simple alias command to do it. But I really want to be able to just type in my alias and let it do its thing and not have to wait to for the yes/no prompt to type in "y". Is there a simple way to bypass this prompt or maybe add "yes" in the alias somewhere?


Sure, although I have never tried it as an alias but it should work:

sudo apt-get update && sudo apt-get -y upgrade
| improve this answer | |
  • I will edit and remove the -y from update if it bothers you One Zero. :) – wojox Apr 2 '12 at 16:04
  • This doesn't work in Trusty. – Cerin Apr 24 '17 at 22:11
  • Doesn't work with grub override conf question. – Waldemar Wosiński Nov 23 '17 at 9:01
  • 2
    For grub override conf question you have to set this in front of it sudo DEBIAN_FRONTEND=noninteractive apt-get... – Watermelon Sugar Dec 14 '18 at 11:33
  • @saitam - thanks.... the DEBIAN_FRONTEND variable is exactly what I was looking for! Kodos. – Hugh Buntu Jul 7 '19 at 18:40
apt-get -o Dpkg::Options::='--force-confold' --force-yes -fuy dist-upgrade"

To clarify Dpkg::Options::='--force-confold' from the man-page:

--force-confold: do not modify the current configuration file, the new version is installed with a .dpkg-dist suffix. With this option alone, even configuration files that you have not modified are left untouched. You need to combine it with --force-confdef to let dpkg overwrite configuration files that you have not modified.

| improve this answer | |
  • 16
    Could you be more specific? What does this command do and how does it work? – Seth Dec 10 '13 at 6:09
  • Nice to see the deeper answer to this question, thanks Vadim. – Alex North-Keys Nov 20 '17 at 17:17
apt-get update && apt-get upgrade -y && apt-get autoremove && apt-get autoclean

This updates the packages, upgrades the packages, removes unused packages, then removes old versions of packages.

You can copy paste that into:

nano -w yourscript.sh


chmod 777 yourscript.sh



So long as you use su before all those steps, which I always do.

| improve this answer | |
  • 4
    This answer goes... too far. He might not want to delete old/unused packages. Also I don't think you should ever use chmod 777 if it can be avoided. And I believe in Ubuntu the recommended way is to use apt-get rather than apt. – Andreas Hartmann Apr 1 '15 at 6:32
  • Agreed, important to answer the actual question, not go further. – jonathan Jan 28 '19 at 20:44
  • 1
    @AndreasHartmann Agreed. That script is a security risk if put on 777. Use chmod u+x instead (only sets the executable bit for the file owner) – 520 Oct 16 '19 at 13:48

You could also do it quietly and then get a notification when it's all done. The downside to this is you will only see errors reported and will not see what is updated.

sudo apt-get update -qq && sudo apt-get dist-upgrade -qq && echo "All up to date now!" && notify-send "All up to date now!"
| improve this answer | |

Defining a function has been the most straightforward, universal method I've found.

I've personally never gotten the update && -y upgrade to work correctly. Some distros have a problem with a single command (or alias) using the && operator and -y argument together.

function update ()
    sudo apt update
    sudo apt -y upgrade
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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