How to add an alias to a command in terminal?
Solution 1
alias new_name='old command'
To create a permanent alias you have to edit the .bashrc
file in your home directory.
More info here
More .bashrc files here
Solution 2
On the bash command line it is simply a case of typing:
alias my_command="Command to run"
For example to create a short command run a long listing you could do:
alias ll="ls -l"
The quotes are not required if you are not adding switches to the aliased command.
Solution 3
To make permanent changes you can put your aliases separetely in ~/.bash_aliases
Solution 4
You can either use the alias
built-in command in the shell you're using, or you can write a script which does what you want. Assuming you are using bash as the shell (which is the default), you can type man bash
and skip down to the ALIASES
section, for documentation on aliases in bash.
Solution 5
I write a GUI for adding/editing alias commands. You can also use it from commandline like this:
addalias -add "sinstall" "sudo apt-get install"
Related videos on Youtube
Rootical V.
Updated on September 18, 2022Comments
-
Rootical V. almost 2 years
By typing a manually specified command in terminal I want to execute some other command.
How could add an alias to a command? Can i do that with the help of the terminal or should I edit some kind of file?
-
dobey about 12 yearsThere is no manual entry for alias. It is a built-in command. You must look at the man page for the shell.
-
OrangeTux about 12 yearsChanged it. ty.
-
Stoyan Dimov over 5 yearsDon't forget to run
source ~/.bash_aliases
for the change to take effect. -
nilsonneto about 2 yearsThis has been flagged for deletion. Can I suggest you add the relevant bits of the link into the answer to make it self contained?