Tuesday, December 30, 2008

usage of alias in konsole

Alias in linux konsole make the users to work faster.

alias - we can create shortcuts for linux commands using the alias.

aliases should be declared in the .bashrc file which located under the $HOME directory

Syntax :

alias mv='mv -iv'
alias cp='cp -v'
alias rm='rm -v'
alias c='clear'
alias l='ls'
alias c='clear'

To remove log files
rmlog='rm -f /home/nobody/server/logs/*'
Shorter find command
alias f='find . -iname '
To start a server after clearing some log files
alias stserver='c;rmlog; cd /home/nobody/server/bin; sh run.sh'


Semicolon ";" is the command seperator in linux, so we can set a key for mulitple commands seperated by semicolon

Even we can execute shell scripts using alias.

We can use our re-use aliases. Here i had declared an alias name rmlog which will delete the log files under logs directory.
I had used the key in another alias named stserver to start a server after cleaning older logs.

FAQ.
* All the aliases gets set when a konsole is initialized.
* If you want to use the newly added aliases in the older window, just execute the below command .$HOME/.bashrc , this will set all the aliases in the older konsole
* typing alias on the konsole will list all the available aliases.
* If you want to set the alias for temporary purpose, then set the alias in the konsole itself using the same way as above. But this will not be available on other konsoles.

No comments: