Linux first week study notes (17)

Source: Internet
Author: User

Linux first week study notes (+)


2.10 Environmental Change TH amount PA

PATH : Just join the PATH path can be opened directly to the command, you can not run the absolute path of the command. This is where the environment variables are working.

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. 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 rmdir

/usr/bin/rmdir

[Email protected] ~]# echo $PATH

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

which the instruction will be in the environment variable $PATH In the set directory to find the command that meets the criteria, i.e. which directly in $PATH The absolute path of the Direct Lookup command in the set directory is faster, if the command you typed is $PATH set directory, you do not need to type the absolute path of this command directly into the command.

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

Experiment Run ls and /usr/bin/ls The effect is the same, that is to say ls in the $PATH in the Set directory, type it yourself . ls you can do it.

[[email protected] ~]# which LS

Alias ls= ' ls--color=auto '

/usr/bin/ls

[[email protected] ~]# ls

Anaconda-ks.cfg

[Email protected] ~]#/usr/bin/ls

Anaconda-ks.cfg

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

Copylscommand to/tmp/Create a new directory underLS1the name of the new well after we run the "LS1"The absolute path is available, if you are using directLS1that's because/tmp/directory is not in$PATHset in the directory so you cannot type directlyLS1Command

[[email protected] ~]# which LS

Alias ls= ' ls--color=auto '

/usr/bin/ls

[Email protected] ~]# CP/USR/BIN/LS/TMP/LS1

[Email protected] ~]#/TMP/LS1

Anaconda-ks.cfg

[Email protected] ~]# LS1

-BASH:LS1: Command not found

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

If you want to use LS1 Then you need to change the environment variable to the Span style= "font-size:19px;color:red" >/tmp/ This directory is added to the $PATH ls1 directory /tmp/ add to $PATH Set the directory to run the ls1

[Email protected] ~]# path= $PATH:/tmp/

[Email protected] ~]# echo $PATH

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

[Email protected] ~]# LS1

Anaconda-ks.cfg

[email protected] ~]# which LS1

/tmp/ls1

[Email protected] ~]#

The above two experiments are the role of environmental variables and implications

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

when we opened a new terminal, we found LS1 It's not working anymore, check it out. $PATH set the directory under /tmp/ The catalog doesn't exist anymore, so we need to do a permanent setup .

[Email protected] ~]# LS1

-BASH:LS1: Command not found (cannot run on new terminal)

[Email protected] ~]#

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

edit / profile/ file added in last line path= $PATH:/tmp/, This opens the terminal to see $PATH Set the directory, type LS1 Span style= "font-size:19px;font-family: Arial" > You can use

directly.

[email protected] ~]# Vi/etc/profile ( Edit Profile the file is added on the last line path= $PATH:/tmp/ )

[Email protected] ~]# echo $PATH

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

[email protected] ~]# LS1 (When you open the terminal again, type LS1 can be used directly)

Anaconda-ks.cfg

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

New Additions LS1 If you don't need it later, you can delete it . LS1 of the

[Email protected] ~]# echo $PATH

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

[Email protected]~] #PATH =/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

[Email protected] ~]# LS1

-BASH:LS1: Command not found

[Email protected] ~]# echo $PATH

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

This is done directly from $PATH The settings directory was deleted. /tmp/ Catalogue

the second method of deletion :

[email protected] ~]# Vi/etc/profile Edit Profile file Delete last line path= $PATH:/tmp/ you can do it.

[Email protected] ~]# echo $PATH

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

query again in $PATH There 's nothing in the Setup directory . /tmp/ catalog.


Linux first week study notes (17)

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.