Linux in the alias instructions to use the detailed

Source: Internet
Author: User

The alias is a naming alias, when some of the instructions you are accustomed to are particularly long, or you add a default option to prevent hand-slipping errors behind certain dangerous instructions.

For example, execute the following command: List all, including hidden documents, and display them by page

[Sun@localhost ~]$ Ls-al | More

Such commands, if you feel too long and annoying, can be set with the alias command:

[Sun@localhost ~]$ alias lm= ' Ls-al | More

Now, using the LM command will get the same effect.



Root can use RM to remove any data, and we need to be careful when we use root, but it's possible to accidentally slip and delete a document that shouldn't be deleted. RM provides an option for us to confirm that the document is deleted

[Root@localhost ~]# rm-i test.txt
Rm:remove regular empty file ' Test.txt '?

Rm-i asks the root user whether to confirm the deletion of the Test.txt document. So we can use the alias to give the RM instruction a default-I option to have the root user force the root to choose whether to delete the document.

[Root@localhost ~]# alias rm= ' Rm-i '
[Root@localhost ~]# RM text.txt
Rm:remove regular empty file ' Text.txt '?

This reduces the likelihood of accidental deletion and uses the alias to see which aliases are set

[Root@localhost ~]# Alias
Alias cp= ' Cp-i '
Alias l.= ' ls-d. *--color=auto '
Alias ll= ' Ls-l--color=auto '
Alias lm= ' Ls-al | More
Alias ls= ' ls--color=auto '
Alias mv= ' Mv-i '
Alias rm= ' Rm-i '
Alias Which= ' Alias | /usr/bin/which--tty-only--read-alias--show-dot--show-tilde '

Unalias Remove Alias, if LM this alias does not want to use again, can delete


[Root@localhost sun]# Unalias lm
[Root@localhost sun]# Alias
Alias cp= ' Cp-i '
Alias l.= ' ls-d. *--color=auto '
Alias ll= ' Ls-l--color=auto '
Alias ls= ' ls--color=auto '
Alias mv= ' Mv-i '
Alias rm= ' Rm-i '
Alias Which= ' Alias | /usr/bin/which--tty-only--read-alias--show-dot--show-tilde '

Related Article

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.