Linux alias List, Set, Create & Remove with alias Command
The alias command creates another name for a command. It does not replace the command name. It simply gives another name to it. It begins with the keyword alias and the new name for the command, followed by an equal sign and the command it will reference.
Viewing aliases
The alias command without options and arguments displays all aliases applied to the user who runs it.
$alias

Creating aliases
You can create aliases in the following ways.
- For a specific user
- Temporary for the current session only
- Permanent for all upcoming sessions
- Permanently for all users
- For new users only
Creating temporary aliases for a specific user
The alias command with arguments creates a new alias. If an alias with the same name exists, it updates it with the new value. It uses the following syntax.
$alias [alias name]=[command]
The following command sets an alias for the ls command.
$alias list=ls

Do not add a space around the equal sign. Use single quotes to create an alias for a command with options and arguments.
$alias [alias name]='[command option arguement]'
The li command with the -s option lists files and their size in blocks. The following command creates an alias for it.
$alias listsize='ls -s'

The alias created on the shell prompt remains available only during the current session. Shell removes them when the user exits the current session. To verify it, log out the user account.

Log in again and recheck the alias.

Creating permanent aliases for a specific user
The ~/.bashrc file defines permanent aliases for the user. Shell runs it when the user logs in. It has a section for the custom alias. Add your custom alias in this section. Let us take an example. Open the ~/.bashrc file. Add the following lines to the custom alias section.
alias list=ls alias listsize='ls -s'
Save the file and log out to terminate the current session.

Log in again and check the list and listsize aliases.

Creating/updating aliases for all users
Create a script file in the /etc/profile.d/ directory and add your aliases to it. When a user logs in, Shell executes all script files from this directory to set a custom shell environment. Let us take an example. Windows uses the ipconfig command to display and manage IP configuration. Linux uses the ip addr command for the same. If you use the ipconfig command on Linux, it shows a 'command not found' error. If your network has users who switched from Windows, you can create an alias for the ipconfig command.
Login from the root user and create a file custom.sh in the /etc/profile.d/ directory. Add an alias for the ipconfig command. Save the file and log out from the root user account.

Login with a regular user account and verify the ipconfig alias.

Creating new aliases only for new accounts
The /etc/skel directory contains default user profile files. When we add a new user account, the shell copies all files from this directory to the user's home directory. If we change profile files in this directory or add a new profile file, new user accounts get the updated files with the newly added custom profile file.
Let us take an example. Log in from the root user account. Create a backup of the default .bashrc file file and open it for editing. Add an alias. Save the file. Add a new user account and log out from the root account.

Login from the new user account and verify the alias.

It does not affect existing user accounts. To verify it, log in with an account created before this change and check it.

Deleting/removing aliases
To delete permanent aliases, remove them from their configuration files. To delete a temporary alias, log out from the current session and log in again. Shell automatically removes all temporary aliases when the user logs out.
To remove a temporary alias without logging out or a permanent alias from the current session, use the unalias command. It uses the following syntax.
$unalias [alias-name]
For example, the following command removes an alias called list.
$unalias list

This command removes an alias only from the current session. If the removed alias is set by a configuration file (~/.bashrc, /etc/bashrc, or /etc/profile.d/*), it will be set again automatically at the next login. To delete it permanently, remove it from the configuration file.
The alias command examples for system administration
A software developer frequently uses the following command to list source and object code files ending with a .c or .o.
$ls *.[co]
He can create an alias for it. The following command creates an alias called lsc for it.
$alias 'ls *.[co]'
The rm command deletes all files and folders from the given path. Novice users might accidentally delete all data from the specified path using this command. An administrator can create the following alias to stop users from accidentally deleting important files.
alias rm='rm -i'
The -i option forces the rm command to take permission before deleting each object.
The cp command copies the given object from the source to the destination. The mv command moves the given object from the source to the destination. If the destination contains an object with the same name, both commands overwrite it. You can use the -i option with both commands to stop this. When using the -i option, both commands check the destination before writing to it. If the destination contains an object with the same name, they take permission from the user before overwriting.
alias cp='cp -i' alias mv='cp -i'
This tutorial is part of the tutorial series 'User profile files, environmental variables, and aliases in Linux'. Other parts of this series are the following.
Chapter 01:- Linux User Profile Management and Environment Variable
Chapter 02:- Linux Environment Variables List, Set, Create & Remove
Chapter 03:- Linux alias List, Set, Create & Remove with alias Command
Conclusion
Aliases create another name for existing commands. You can create new or update existing ones to customize the shell environment. The /etc/bashrc file defines the default aliases for all users. The /etc/profile.d/* files override the default aliases for all users. The ~/.bashrc file overrides the default aliases for the particular user.
By ComputerNetworkingNotes Updated on 2026-06-05