Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

How to create command aliases in linux? For example, I'd like to make alias for ssh root@host

Thank you?

share|improve this question
    
As another option you may want to man ssh_config and consider creating a .ssh/config. Using this file you can set default login users for particular hosts. For example if you have a lot of switches that use an 'admin' user, you might add an entry for those so you can just ssh switch1 without having to remember 'admin@'. –  Kyle Smith Dec 18 '10 at 23:40

3 Answers 3

up vote 5 down vote accepted

Which shell?

Assuming bash, put this kind of thing in your .bashrc:

alias srhost="ssh root@host"
share|improve this answer

Only for your user, edit your .bashrc

alias srhost="ssh root@host"

To add Alias

alias newcommand="yourcommand -arguments"

To remove Alias

unalias newcommand

share|improve this answer

I like to create a .bash_aliases file for portability between my systems I use. add this to your .bashrc

if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi

you can then add aliases to this file such as

alias psg='ps -auxww|grep'

also after adding a alias you will need to exit/open your terminal so the changes will take affect.

OR try

source ~/.bashrc

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.