Alias in shell refers to giving another name to a command or group of commands. It is very useful when a name of a command is long. With the help of alias, we can avoid typing a bigger name and invoke a command by a name as per your convenience.
To create an alias, alias shell builtin command is used. The syntax is as follows:
alias alias_name="Commands to be aliased"
To print a disk space in a human-readable format, we use the
df command with the
-h option. By making alias of
df -h to
df, we can avoid typing again and again
The output of the
df command before aliasing it to
df -h is shown in the following screenshot:
Now, to create alias for df -h to df, we will execute the following command:
$ alias df="df -h" # ...