Linux Command-alias: set or show aliases

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.