How to create, change, and delete aliases in Linux
An alias is another name for a command. You can use the alias command to create, change, and manage aliases on Linux. By default, the alias command creates and updates aliases in the current session. To manage them permanently, you need to modify configuration files.
The alias command
The alias command creates an alias for an existing command. You can use an alias as the substitute for the command. For example, if you use a long command frequently, you can create a short alias for that command. After creating an alias, you can use the created alias instead of the command. This way, aliases improve efficiency and avoid potential spelling errors.
The alias command syntax
The alias command uses the following syntax.
alias alias_name='value'
alias:- This is the command.
alias_name:- It defines the new alias name for the actual command. It can be any user-defined string, excluding special characters and the words alias and unalias. The words alias and unalias are the command keywords.
value:- It specifies the actual command the alias references. The command can also include options, arguments, and variables.
Listing the existing aliases
Linux automatically creates aliases for frequently used commands. The following command lists the default aliases.
#alias

Creating aliases
There are two ways to create aliases: temporary and permanent. A temporary alias works only in the current session. Linux automatically deletes it when the user logs out from the current session or shuts down the system. A permanent alias remains available until the user manually deletes it.
Creating and managing temporary aliases
The following command creates an alias for the current session.
#alias alias_name='actual_command'
The following command creates an alias command lh for the actual command ls -l /root.
#alias lh='ls -l /root'

Deleting or removing temporary aliases
Linux automatically removes a temporary alias when you exit the current session or restart the system. But if you want to delete it immediately, you can use the unalias command. The following command deletes the lh alias.
#unalias lh

Creating/deleting permanent alias
To create a permanent alias, you need to add the alias in the .bashrc file. The shell reads this file when the user logs in. Open this file.

Add your alias at the end of the alias section and save the file.

Log out from the current session.

The custom alias will be available from the next session.

To delete a permanent alias, open the .bashrc file, remove the alias you want to delete, save the file, exit the current session, and log in again.
Conclusion
Linux administrators commonly use aliases for convenience. Aliases allow them to create easy-to-remember shortcut commands for long commands. It also reduces common typing errors.
By ComputerNetworkingNotes Updated on 2026-02-13