0

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

Thank you?

1
  • 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, 2010 at 23:40

3 Answers 3

6

Which shell?

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

alias srhost="ssh root@host"
2

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

0

Only for your user, edit your .bashrc

alias srhost="ssh root@host"

To add Alias

alias newcommand="yourcommand -arguments"

To remove Alias

unalias newcommand

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .