How To Use alias Command in Linux

In Linux, commands help you achieve tasks like troubleshooting network issues, executing scripts, organizing system structure, and more. Moreover, some situations require you to run lengthy commands repeatedly, and typing them consumes much of your time. In this case, the alias command is the savior, creating shortcuts for long commands or a sequence of commands. It also improves productivity and reduces errors.

However, many users and even Linux experts have yet to learn how to use the alias command correctly. So, this short tutorial will quickly explain how to use the alias command in Linux without any hassles.

The alias Command with Examples

The alias command is simple, and you can use it as:

alias alias_name=‘command’


Please replace the ‘alias_name’ and ‘command’ with the name of the alias and the target command, respectively. In simple words, alias means the shortcut command you want to create. For instance, you can create the following alias if you frequently use the ‘sudo apt update && upgrade’ command to update the system:

alias update=‘sudo apt update && upgrade’

Now, whenever you type and run ‘update’ in the terminal, the system will automatically start updating:


The above aliases last only for the current terminal session. However, if you want to make a persisting alias, add it to your shell’s configuration file. Typically, for Bash, it is the ‘.bashrc’ file. Let’s retake the above example to convert ‘update’ to a permanent alias. First, you have to open the configuration file with a text editor:

After that, add the aliases in the following manner:

alias update=‘sudo apt update && upgrade’


Finally, save the file and run the ‘source ~/.bashrc’ command to apply the changes.


A Quick Wrap-up

The alias command in Linux empowers a user to customize the command line experience and enhance productivity. By creating personalized shortcuts, you can easily streamline your workflow and navigate your system. Here, we discussed the method to create temporary and permanent aliases. Furthermore, remember all the mentioned tips to maintain clarity and efficiency.


Leave a Comment