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.
In this tutorial you will learn:
- How to create permanent alias on Linux
- How to use alias on Linux
- How to view configured aliases
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – 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
~/.bashrcfile. 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
docswhich executes the command
alias docs='cd /home/linuxconfig/Documents/'
- After saving your changes and exiting the file, execute the following command to make the changes take effect:
$ source ~/.bashrc
- Now we can use our newly configured alias in the command line.
- To check your configured aliases, along with the new one you just set, execute this command:
$ alias -p
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