How to modify the PATH environment variable
1.1 What is an environment variable
1.linux where all can be used, the content will not change generally
2. Uppercase
3.PATH LANG
4. When modifying environment variables, add export before
1.2 Path meaning function
The path variable contains the location of the command under Linux.
1.3 The process of running commands under Linux
# # # #1) input ls
# # # #2) LS is in these paths/directories in path
# # # #3) If any, perform the parsing
# # # #4) If not then prompt command not found
1.4 Simulation Environment
# #1. Switch to Root
# #2. Modify Path
[Email protected] ~]# WhoAmI
Root
1.5 Modify Path
[Email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[Email protected] ~]# Exportpath=/usr/local/sbin:/usr/local/bin:/bin:/usr/sbin:/usr/bin:/root/bin
[Email protected] ~]# ifconfig
-bash:ifconfig:command not found
[Email protected] ~]# Ls-l/sbin/ifconfig
1.6 Recovering PATH----Temporary
[Email protected] ~]# Exportpath=/usr/local/sbin:/usr/local/bin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin
[Email protected] ~]# ifconfig
[Email protected] ~]# Exportpath=/usr/local/sbin:/usr/local/bin:/bin:/usr/sbin:/usr/bin:/root/bin:/sbin
1.7 Methods for permanent modification
Vim/etc/profile
1. How Linux modifies the PATH environment variable
2.1. Temporary
3. [[Email protected] ~] #exportPATH =/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
4.2. Permanent
5. Append the command Exportpath=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin to the/etc/profile
6.
7.3. Entry into force
8.1) Re-login
9.2) source
1.8 Problem: "centos5.x" when cutting from the root user to the normal user Oldboy, the execution ifconfig will prompt-bash:ifconfig:command not found ask why is this? How to resolve, please give a detailed resolution process.
Answer:
Linux command execution process
First step: View the currently used system version
[Email protected] ~]# cat/etc/redhat-release
CentOS Release 6.9 (Final)
Step two: Find out if you have this command path (command paths/locations) bash built-in
[Email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Step three: Temporarily modify the PATH environment variable
Export path=
Fourth step: Permanently modify the PATH environment variable
Vim/etc/profile
Paste the temporarily modified environment variable command in the unchanged order
Fifth Step: Effective
. /etc/profile or Source/etc/profile
This article is from the "Heyong" blog, make sure to keep this source http://heyong.blog.51cto.com/13121269/1954920
Modifying the PATH environment variable in Linux