Aliases are shortcuts for certain commands. For example, if your current directory is /usr/bin and you want to navigate quickly to /var/cache/apt/archives you can do a “cd /var/cache/apt/archives”, but this is quite long and you probably want to save time. So this is where aliases come in help. You can do only a “archive” or a “pak” command and the same action is accomplished.
First, edit your ~/.bashrc
and make sure that it contains the following three lines (if not add them editing the file)
if [ -f ~/.bash_aliases ]; then
After this all you have to do is edit your ~/.bash_aliases file and add your own aliases.
alias dld=’cd ~/downloads’
alias x11=’nano /etc/X11/XF86Config-4′
alias pak=’cd /var/cache/apt/archives’
Save and exit the file.
In the above examples, “dld”, “x11” and “pak” commands will execute the exact command from the right side of the equal sign.
Why bother with the extra file, just put the aliases directly in the ~/.bashrc file.
Excellent, now when I type urnar instead of unrar it still works!
Have a look at the ZSH instead of Bash. It has a autocorrection feature… Happy mistyping 🙂
I suppose everyone who can edit files using VI can already set aliases in .bashrc 🙂
Totally insane to use aliases for cd, IMHO
Why not use the CDPATH variable instead.
now “cd archives” will look in current dir, then /var/cache/apt, and ~/
Automake fails when using bash and CDPATH is set. If you’re a developer or build your programs from source it can be annoying sitting there for a few minutes until you remember the build is failing because the CDPATH environment variable is set. I’m not sure if that bug has been fixed yet.
IMO, the best and safest solution is to either use tab completion or learn how to type.
I use it for SSH sessions, and prefer this file instead of .bashrc to get a clear overview
It unfortunately does not work (running on Raspbian = Debian Jessie). Whenever a new SSH session is opened, there is no alias. Any ideas?!?