When a command is too long or does not conform to the user's habits, you can specify an alias that conforms to the user's habits for the command. For example, users of the custom DOS command can use the alias md= ' mkdir ' command to replace the MD with the mkdir. Sometimes a commonly used option is added for frequently invoked commands, such as alias ls= ' ls--color=auto '.
There is a small problem with defining aliases at the command line: when the shell session ends, these aliases disappear as well. If an alias is required to be valid for a long time, the alias command needs to be written to the initialization script.
Command format
Alias:alias [-P] [Name[=value] ...]
Command parameters
-P
Displays all defined aliases in a reusable format.
Instance
A) displays all defined aliases.
aliasalias l.= ' ls-d. *--color=auto ' Alias ll= ' Ls-l--color=auto ' Alias ls= ' ls--color=auto ' Alias vi= ' vim ' Alias Which= ' Alias | /usr/bin/which--tty-only--read-alias--show-dot--show-tilde '
b) define aliases.
alias copy= ' CP ' copy/etc/passwd./passwd [Email protected] cmdline]$ LSPASSWD
c) Remove the alias.
unalias Copy [Email protected] cmdline]$ type copy-bash:type:copy:not found
Related commands
Unalias-Remove aliases
Linux Command-alias: set or show aliases