This is something useful that I discovered last week. It allows you to use shortcuts (aliases) for long commands that you type often. For example, it is much easier and faster to type “agi <package name>” than “sudo apt-get install <package name>”
First, we need to edit our ~/.bashrc file (~/ signifies your home directory).
sudo gedit ~/.bashrc
Now paste the following lines in the bottom of that file:
alias acs=’apt-cache search’
alias agu=’sudo apt-get update’
alias agg=’sudo apt-get upgrade’
alias agd=’sudo apt-get dist-upgrade’
alias agi=’sudo apt-get install’
alias agr=’sudo apt-get remove’
alias agc=’sudo apt-get clean’
alias aga=’sudo apt-get autoremove’
Save the file. To apply the settings, run “source ~/.bashrc” in a terminal. (Thanks to Endpoint for this tip.)
Now once the settings are applied, you can just follow the model I mentioned in the beginning of this post for installing, removing, etc. packages.
Tip suggested by Alex from The Spinning Cortex
If you eventually want to create more aliases and want to store them all in a separate file, you can create a file called .bash_aliases in your home directory:
gksudo gedit ~/.bash_aliases
You now must enable this file in your ~/.bashrc:
gksudo gedit ~/.bashrc
Now find the lines that look like this:
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
#if [ -f ~/.bash_aliases ]; then
# . ~/.bash_aliases
#fi
Uncomment the bottom three, so that they look like this:
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
Now you can restart the X server and your aliases will be stored in ~/.bash_aliases instead of ~/.bashrc. This is useful if you have a lot of aliases and don’t want to continually mess with ~/.bashrc since it’s an important file.