Linux first week study notes (13)

Source: Internet
Author: User

Linux first week study notes (+)


2.5 . alias command

alias command: alias " causes the original command to prevent special characters from causing an error. alias

Unalias command: used to cancel the command alias, which is the Shell built-in commands. If you need to cancel any of the command aliases, use the command alias as a parameter option for the directive. If you use -a an option, it means that all existing command aliases are canceled.

daizhihong= ' Ls-lha ' (create aliases)

Unalias Daizhihong (cancel alias)

--------------------------------------------------------------------------------------------------------------- --------------------------------------

To view aliases for all commands:

[[email protected] ~]# alias (see aliases for all commands)

Alias cp= ' Cp-i '

Alias egrep= ' Egrep--color=auto '

Alias fgrep= ' Fgrep--color=auto '

Alias grep= ' grep--color=auto '

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 '

--------------------------------------------------------------------------------------------------------------- -----------------------------------------

To create a definition alias:

[Email protected] ~]# Daizhihong

-bash:daizhihong: Command not found

[[email protected] ~]# alias daizhihong= ' Ls-lha ' (create aliases)

[[email protected] ~]# Daizhihong (execution result of "Ls-lha" command after running "Daizhihong")

Total Dosage 28K

Dr-xr-x---. 3 root root 147 1 months 22:37.

dr-xr-xr-x. Root root 265 1 Month 22:48.

-RW-------. 1 root root 1.4K 1 months 08:19 anaconda-ks.cfg

-RW-------. 1 root root 935 1 Month 05:47. Bash_history

-rw-r--r--. 1 root root for each month , bash_logout.

-rw-r--r--. 1 root root 176 month . Bash_profile

-rw-r--r--. 1 root root 176 month . BASHRC

-rw-r--r--. 1 root root for the month of CSHRC.

drwx------. 2 root root 1 months 04:29. SSH

-rw-r--r--. 1 root root 129 month . TCSHRC

[email protected] ~]# which Daizhihong

Alias daizhihong= ' Ls-lha '

/usr/bin/ls

--------------------------------------------------------------------------------------------------------------- ------------------------------------------------------

To cancel an alias:

[email protected] ~]# Unalias daizhihong (cancel alias)

[Email protected] ~]# Daizhihong

-bash:daizhihong: Command not found

--------------------------------------------------------------------------------------------------------------- ------------------

which command: Used to find and display the absolute path of a given command, environment variables PATH The directory that needs to be traversed when the find command is saved. the which directive looks for eligible files in the directory where the environment variable $PATH set. That is, with the which command, you can see whether a system command exists, and the command that executes exactly which location.

[[email protected] ~]# which LS

Alias ls= ' ls--color=auto '

/usr/bin/ls

[email protected] ~]# which LL

Alias ll= ' Ls-l--color=auto '

/usr/bin/ls

PATH : The system environment variable is an alias path, and if a command is under this directory, running the command directly can take effect. If it doesn't work under the directory, this is what PATH does .

Echocommand:used inShellPrint inShellThe value of the variable, or the specified string is output directly. Linuxof theEchocommand, inShellextremely popular in programming, Print variables under the terminalvalueIs often used, so it is necessary to understand theEchousage ofEchothe function of the command is to display a piece of text on the display, which generally acts as a hint.

[Email protected] ~]# echo $PATH

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin


Linux first-week study notes

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.