Alias is an Linux command provides ability to create customized commands. Using this you can create a sort name for a big command as an alias, which is easier to remember. When we uses a single command very frequently, we can alias them to a very short name. You can understand it as create shortcut commands on Linux.

Create Shortcut Command

For example, we use below command frequently to view the directory listing in human readable format. Now, make it short with alias command. All done, You have created the alias successfully. To verify the newly created alias, just type below command on terminal

You will see the results on screen similar to command “ls -lh”.

Make Shortcut Permanent

When you create an alias on terminal, it is not available permanently. Once the terminal is closed, the aliase are lost. To make the aliases permanently you can write in login or non login shell script. Add the aliases in /etc/profile.d/bash_aliases.sh (Use any name for this script) to make them available for all users. To configure aliases for specific user only, add them in ~/.bash_aliases file.

Create More Shortcut Commands

You can create multiple shortcut commands as much you need. Here is the aliases of some frequently used commands. Add these commands to shell script.

View all Shortcuts (Aliases)

You can simply type the “alias” command without any parameter to print all available aliases on your system.

Remove Shortcuts

You can use unalias command to disable any shortcut on your system. For example to disable ‘lh’ alias use following command. You also need to remove any entry made in login or non login shell scripts.

How to Create Shortcut Commands in Linux   TecAdmin - 45How to Create Shortcut Commands in Linux   TecAdmin - 84