O'Reilly logo

Linux Shell Scripting Essentials by Sinny Kumari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Alias

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"

Creating alias

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 df -h.

The output of the df command before aliasing it to df -h is shown in the following screenshot:

$ df

Now, to create alias for df -h to df, we will execute the following command:

$ alias df="df -h" # ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required