Jan 052009

Sponsored Link

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

#vi ~/.bashrc

and make sure that it contains the following three lines (if not add them editing the file)

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases

After this all you have to do is edit your ~/.bash_aliases file and add your own aliases.

#vi ~/.bash_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.

Sponsored Link

 Posted by at 12:17 am

  8 Responses to “Howto Create your own aliases in Debian”

  1. Why bother with the extra file, just put the aliases directly in the ~/.bashrc file.

  2. Excellent, now when I type urnar instead of unrar it still works!


  3. @Wolfric:

    Have a look at the ZSH instead of Bash. It has a autocorrection feature… Happy mistyping 🙂

  4. I suppose everyone who can edit files using VI can already set aliases in .bashrc 🙂

  5. 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 ~/

  6. 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.

  7. I use it for SSH sessions, and prefer this file instead of .bashrc to get a clear overview

  8. It unfortunately does not work (running on Raspbian = Debian Jessie). Whenever a new SSH session is opened, there is no alias. Any ideas?!?

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>