To create and use alias commands in Linux, follow these steps:
1. Create an Alias:
You can define an alias using the alias command. For example:
alias ll=’ls -l’
This creates an alias ll for the command ls -l, so typing ll will run ls -l.
2. Make Alias Permanent:
To make your alias available in every session, add it to your shell configuration file (e.g., .bashrc or .bash_profile for Bash). Open the file with a text editor:
nano ~/.bashrc
Add your alias command at the end of the file:
alias ll=’ls -l’
Save and close the file. Then, apply the changes:
source ~/.bashrc
3. List Aliases:
To view all active aliases, use the alias command:
alias
4. Remove an Alias:
To remove an alias, use the unalias command:
unalias ll
Now, you can use aliases to save time and simplify command execution!