Howto Create your own aliases in Debian

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
fi

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

#vi ~/.bash_aliases

Examples

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

8 thoughts on “Howto Create your own aliases in Debian

  1. @Wolfric:

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

  2. Totally insane to use aliases for cd, IMHO

    Why not use the CDPATH variable instead.

    eg.
    CDPATH=.:/var/cache/apt:~/

    now “cd archives” will look in current dir, then /var/cache/apt, and ~/

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

  4. 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 comment

Your email address will not be published. Required fields are marked *