Creating an alias for use on the command line can save the user from typing long commands, common options, or typos. This will save you some time and repetitive keystrokes, and ultimately make your command line experience even more efficient. In this tutorial, we will take you through the step by step instructions to create a permanent alias on a Linux system.
Privileged access to your Linux system as root or via the sudo command.
Conventions
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command $ – requires given linux commands to be executed as a regular non-privileged user
How to create permanent alias on Linux
To create a permanent alias, we will need to edit the ~/.bashrc file. You can open this file with nano or your preferred text editor.
$ nano ~/.bashrc
At the bottom of this file, you can add your permanent alias. As an example, we will make a simple alias docs which executes the command cd ~/home/linuxconfig/Documents/.
In this tutorial, we saw how to create a permanent alias on a Linux system. As this is a permanent alias, the setting will persist after subsequent reboots. If you need to remove the alias in the future, you will have to delete the line from the ~/.bashrc file.