Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to create a shortcut for a command in terminal. Like for a command "ssh user@", I just want a command "user" and the above command will run. Is this possible, and if so how can it be done?

Thank you!

share|improve this question

3 Answers 3

The shortcuts for commands are known as aliases.
The syntax to create an alias is:

alias custom_command='original_command'  

For creating an alias for update and upgrade we should type the following in terminal,

alias update='sudo apt-get update'    

alias upgrade='sudo apt-get upgrade'  

So to create an alias for your command open the termianl and type:

alias user='ssh user@'
share|improve this answer
If you want to have this command available in every terminal, you need to add this line to ~/.bash_aliases. Then it will be automatically loaded. –  panmari Aug 3 '13 at 9:47
thank you tarun... –  rohit Aug 3 '13 at 9:50
i dont have any ~/.bash_aliases file should i create it? –  rohit Aug 3 '13 at 9:55
That depends on your ~/.bashrc . Does it source ~/.bash_aliases ? If yes, then just create it. –  ahilsend Aug 3 '13 at 9:58
@rohit the .bash_aliases file is not a standard bash feature (I think it is an Ubuntu thing), the standard way is to add alias definitions to your .bashrc file. –  terdon Aug 3 '13 at 15:17

Aliases can take parameters. For example:

$ alias 777='sudo chmod -R 777 '
$ 777 MyFolder

will perform chmod recursively on MyFolder

share|improve this answer

Generally the answer is to alias your command, as mentioned by M.Tarun. For your example with ssh you might want to add it to your .ssh/config:

Host someName
     User user

Then call ssh with the name:

$ ssh someName

Your shell probably also has tab-completion for ssh. So you can just type ssh s and then hit Tab.

This also has the advantage that it works with other commands like scp:

$ scp some-file someName:a/path/

Whereas the alias approach would not work with this.

share|improve this answer

Your Answer


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.