How To Create Linux Alias for Two Commands?

Linux alias is used to create an alias for the Linux commands with their options or parameters. The alias is generally used for a single command but there is no restriction on the command count. We can use the Linux alias to create an alias for two or more commands or simply multiple commands.

Create Alias for Two Commands

The alias keyword is used to create an alias for two commands. These commands are used like a bash script. Just put them and separate them with a semi-colon. In the following example, we create the alias named list . The list alias executes two ls commands.

alias list = "ls /home/ismail;ls /home/ahmet"

Alternatively, different two commands can be used to create an alias with two commands.

alias cf = "touch db.txt;file db.txt"

Create Alias for Multiple Commands

An alias can be created with more than two commands. Similar to the two command method multiple commands can be used for an alias. We again use the semi-colon in order to use and separate multiple commands from each other.

alias cf = "touch db.txt;file db.txt; cat db.txt"

Leave a Comment