You can create shortened commands by using aliases. Aliases are very convenient to use for frequently used commands.
sudo apt-get upgradecan be shortened to
sudo apt-get installcan be shortened to
sudo apt-get removecan be shortened to
sudo apt-get update && sudo apt-get upgrade && sudo apt-get autoremove && sudo apt-get autocleancan be shortened to
Assuming you are using Bash, create a
.bash_aliases file in your users home directory, if it already doesn’t exist:
Open up your
Then, add a lines with the following to the file:
alias apt='sudo apt-get' alias update='sudo apt-get update && sudo apt-get upgrade && sudo apt-get autoremove && sudo apt-get autoclean'
To apply the changes immediately to your bash profile without having to log out, simply run this:
Now you can install any new package with the syntax:
apt install <package-name>
sudo has been added to your alias, you don’t have to type it every time. It will prompt you to use the password the first time, and won’t ask again for the duration of the defined timeout period.
Do note that autocompletion will not work with the alias.
Although these examples have been geared towards Debian and Ubuntu, you can obviously use aliases on any Unix-like operating system. The technique of applying them just varies depending on the shell environment you are using.
~/.bash_aliases file does not work, then add aliases to the end of
~/.bash_profile. For example, in Mac OS X you must create
~/.bash_profile file and then add the aliases.
If this article has helped you then please leave a comment
Thanks for reading!