alias
Command in Linux
Summary
The alias
command in Linux allows you to create shortcuts for frequently used commands. This can significantly speed up your workflow by simplifying complex commands or long sequences of commands into shorter, more memorable aliases.
Introduction
The alias
command in Linux is used to define or display aliases. An alias is essentially a shortcut for another command or a sequence of commands. When you type an alias, the shell replaces it with the actual command or sequence of commands before executing it. This is a great way to customize your shell environment and make common tasks easier.
Use case and Examples
Creating a simple alias
This creates an alias namedla
that executes the command ls -la
(which lists all files and directories, including hidden ones, with detailed information). Listing all defined aliases
This command displays a list of all currently defined aliases in your shell session.Creating an alias for navigation
This creates an alias namedback
to quickly navigate back to the parent directory. Unalias a previously created alias
This command removes the aliasla
that was previously defined. Making aliases permanent
To make aliases permanent, you need to add them to your shell configuration file (e.g., .bashrc
, .zshrc
). Open the file with a text editor:
Commonly used flags
Flag | Description | Example |
---|---|---|
-p | Prints the alias definitions in a reusable format. | alias -p |
(No Flag) | Without any arguments, it lists all current aliases. | alias |
N/A | To unalias a previously defined alias, use the unalias command. | unalias myalias |