Tuesday, December 30, 2008

alias

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 for commands" 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 p='pwd'
alias c='clear'
alias cmo='chmod 755 *.bin;./*.bin'
alias l='ls'
alias c='clear'
alias f='find . -iname '
alias rmlog='cd /home/nobody/server/logs;rm -f *.log'
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 previous aliases in the further 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: