alias Command: Tutorial & Examples
Create a shortcut for a command
The alias
command in Linux is a command-line utility that allows you to create custom shorthand commands for frequently used commands. The basic syntax for creating an alias
is alias [shortcut_name='long command']
.
For example, if you frequently use the ls -al
command to list the files in a directory with detailed information, you can create an alias for it like this: alias ll='ls -al'
.
Now, instead of typing ls -al
, you can use the shortcut ll
to run the same command.
You can also use the alias
command without any options to list all the current aliases that you have created.
Another way to create an alias is to add it to your shell configuration file, typically ~/.bashrc
for bash
shell, so the alias will be available every
time you open a terminal. It will look like alias ll='ls -al'
in the file.
It is important to note that the alias only exist in the current shell session, if you want to make it permanent you should add it to the shell configuration file. Also, if you create an alias that has the same name as an existing command, the alias will take precedence over the original command.