One single command to update everything in Ubuntu?
There are 3 decent choices:
You could create a script something like the following:
#!/bin/bash set -e sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade
Call it something like
update.sh
and place it in/usr/local/bin
and then make the script executable by running:sudo chmod +x /usr/local/bin/update.sh
Another method would be to create a bash alias (in
~/.bashrc
) or wherever you normally store your aliases:alias update='sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade'
A final method would be to simply string the 3 commands together on the commandline:
sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade
A few choices...
Reference:
- Combine apt-get update and apt-get upgrade in one command
We can have a one-liner command (no need to scripts, just copy-paste)
sudo apt update -y && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt clean -y && sudo apt autoclean -y
update
- updates the list of packages but do not installupgrade
- install new versions of packages if new versions are availablefull-upgrade
- performs the function of upgrade but will remove currently installed packages if this is needed to upgrade the system as a whole (fixing bad dependencies then)autoremove
,autoclean
andclean
- clean old packages which are not needed any more- option
-y
does not request for permission on every step &&
states that it just runs the next command if the previous was successfully executed
If you are annoyed by too much typing, you can define yourself an "alias". This can be done e.g. by adding a line to the end of your $HOME/.profile
like this:
alias sau='sudo aptitude update && sudo aptitude upgrade'
(of course you can replace "sau" by something else -- for me that's an acronym to Sudo Apt-get Update). After saving the file, open a new shell (or "source" the .profile again running . $HOME/.profile
. Now you can always simply type "sau" to do the complete job. Works great for me with multiple machines.