RSS

LINUX make a command alias

20 Dec

Make aliases permanent (bash syntax)

The alias c remains in effect only during the current login session. Once you logs out or reboot the system the alias c will be gone. To avoid this problem, add alias to your ~/.bashrc file, enter:

 
vi ~/.bashrc

The alias c for the current user can be made permanent by entering the following line:

 
alias c='clear'

Save and close the file. System-wide aliases (i.e. aliases for all users) can be put in the /etc/bashrc file. Please note that the alias command is built into a various shells including ksh, tcsh/csh, ash, bash and others.

A note about privileged access

You can add code as follows in ~/.bashrc:

 
# if user is not root, pass all commands via sudo #
if [ $UID -ne 0 ]; then
    alias reboot='sudo reboot'
    alias update='sudo apt-get upgrade'
fi

---

A good use of alias to write less parameter and also to hide passwords e.g.:

alias sql='sqlplus apps/apps'

————

Cheers

Muhammad Rashed.

 
1 Comment

Posted by on December 20, 2012 in OS

 

Tags: , ,

One Response to LINUX make a command alias

Leave a Reply