Linux Alias Command
The alias command in Linux is used to create shortcuts for long or frequently used commands. This can save time and reduce errors when typing commands.
Basic Syntax
alias name='command'
Here, name is the shortcut name, and command is the full command you want to alias.
Example
Suppose you frequently use the ls -la command to list all files with detailed information. You can create an alias for it:
alias ll='ls -la'
Now, typing ll will execute ls -la.
Making Aliases Permanent
Aliases created using the alias command are temporary and will be lost after you close the terminal. To make them permanent, add them to your shell configuration file:
- For
bash: Add the alias to~/.bashrc - For
zsh: Add the alias to~/.zshrc
Example:
echo "alias ll='ls -la'" >> ~/.bashrc
Then, reload the configuration file:
source ~/.bashrc
Removing an Alias
To remove an alias, use the unalias command:
unalias ll
This will remove the alias ll.