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:
To clarify
Dpkg::Options::='--force-confold'
from the man-page:This updates the packages, upgrades the packages, removes unused packages, then removes old versions of packages.
You can copy paste that into:
then
then
So long as you use
su
before all those steps, which I always do.@wojox answer is correct, but you can take the alias even further for more functionality. I have been using this for quite some time now without issue. This will perform the upgrades (confirming with
-y
) and then testing to see if a reboot is required. If a reboot is required, you can do so by pressing[ENTER]
, or cancel and reboot later by pressing[CTRL+C]
. If no reboot is required, the alias finishes letting you know so.My alias is
sur
for "sudo upgrade reboot", but feel free to name it what you choose. Add the following to your.bashrc
file:You can continue to chain more commands if you would like to do more with the same alias. Here is the complete alias from my
.bashrc
that will also remove unused packages:I actually stumbled across this thread while checking to see if there is an option to skip the prompt for configuration file overwrites. Thank you @Vadim for you answer above! My new alias is this:
I then push this new
.bashrc
file to each of my managed servers simply with:while read HOST; do scp .bashrc username@$HOST:/home/username; done < managedhosts.txt
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.
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.