How to add aliases for frequently used commands

From Wiki
Revision as of 12:18, 29 September 2009 by 10.0.7.14 (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

go back to Main Page, Computational Resources, Information & Help, Chemistry & More, Linux & Unix


An Alias is a word that represents a command in your computer. Aliases allow you to define shortcuts and synonyms for commonly used shell commands. You can write aliases in your own PC or in your account on a cluster.

You can add aliases by just typing

alias newcommand='yourcommand -arguments'

examples:

alias q='qstat -u username'

by doing this everytime you tipe q you will obtain the result of a qstat -u username, so you will have to type less letters to obtain the same output.

alias B='cd /home/username/directoryA/diretoryB/'

with this alias you will go from any directory in your PC to directoryB, just typing B.

alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'

These three aliases are very popular and are useful to make sure you don't loose important information, by asking if you really want to remove, move and copy before doing it.

A good option is to write the alias on your .bashrc or .bash_profile (in your home/username/), so you won't need to type it every time you open a new ssh session. (They will become active after executing the modified file: . .bash_profile)