alias Command in Linux

Back

The alias command can be used to simplify a few commands. For the root administrative user, the default aliases a bit of safety. To see the aliases for the current user, run the alias command. The following output is the default Red Hat aliases for the root user.


Definition : 

alias is a built-in shell command in Linux / Unix operating systems. It can save you a lot of typing by assigning a name to long commands. For example, if you need to repeatedly copy files from one directory to another using the command .

Commonly used for a long strings that are frequently used. Alias allows you to have a small more familiar command or name to execute a long string.

# cp  /home/jones/data1/*  /usr/local/share/latest/.

you can replace this long command line with a short easy to remember name like "moveit" using the alias command as follows:

# alias moveit = "cp /home/jones/data1/* /usr/local/share/latest/."



Syntax

alias [name=['command']]

name Specifies the alias name.
command Specifies the command the name should be an alias for.
-a Removes all alias definitions from the current shell execution environment.
-t Sets and lists tracked aliases.
-x Sets or prints exported aliases. An exported alias is defined for scripts invoked by name.


# aliases cp = 'cp -i'
# aliases  l.  = 'ls -d'  .*  --color = auto'