You will be learned about alias in Linux from this article. In the previous article we learned few very basic commands like pwd, ls , cd, vim, touch, cat, less and more. We could learn there are options we can use with the commands like options used with ls command in the previous article.
So, normally we have to use these Linux custom commands frequently. Typing the same command over and over reduces the productivity. Because of that reason we use aliases. What alias do ? It’s like a custom shortcut to represent a command or a set of commands.
Eg : Without typing ls -lrt every time, we can create an alias in one or two characters to represent that command.
1) To view current aliases that have created.
2) How to create an alias ?
Below is the syntax,
alias <shourtcut name> =”Your custom command”
alias t=”ls -lrt” ( We can use “t” to list files sorted by time )
alias h=”ls -lh” ( We can use “h” to list files sorted by file size )
alias sshx=”ssh [email protected]” ( We can use sshx for connecting to serverx with ssh )
* But, above aliases are not permanent. They are active within that user login time. If the user signed out, those aliases will be erased and only permanent aliases will be shown.
3) How to create a alias permanent ?
There is a file named “bashrc” ( a hidden file ) in your home directory. It will be appear as
bashrc file is a shell configuration files. This file will be run in each time of a shell interaction session.
4) What is a shell ?
Shell is a program given to users for interaction with the system. Simply an interpreter that executes commands reading from standard input keyboard or from a file. There are different types of shells in Linux.
- Bash shell
- C shell
- korn shell