How to Create a Permanent Alias in Linux
The Linux operating system uses commands to tell the computer what to do. Most Linux commands are designed to use as few keystrokes as possible. This sometimes makes it hard for beginners to remember what the command does. You can create an alias for the command, if this is the case. An alias is a word that directly references a particular command. The "alias" command sets the alias for a single session. To make it permanent, it must be placed in the user's ".bashrc" file, which is read when you open a shell session.
Instructions
-
-
1
Open a terminal or Konsole window. The "Terminal" (Gnome) or "Konsole" (KDE) application is found under your distribution's main programs menu.
-
2
Type the command "vi .bashrc" to open the hidden bashrc file in the "Vi" text editor. This command will create the file, if one does not exist. You can replace "vi" with your favorite text editor.
-
-
3
Type "alias name=command" in the text file. Replace "name" with the name you want to give the alias. Replace "command" with the command that you want to run with the alias. For example "alias working=pwd" will allow you to type "working" to see the directory you are currently working in.
-
4
Save and close the file.
-
5
Close the terminal and open a new one to make the shell read the new .bashrc file.
-
6
Type the alias name at the command prompt to ensure that it works correctly. For example, type "working" at the command prompt.
-
1
Tips & Warnings
To make the alias work for all users, place the alias line in the "/etc/bashrc" file.