View of system environment variables:
[Root@localhost ~]# Env
Hostname=localhost.localdomain
Selinux_role_requested=
Term=xterm
Shell=/bin/bash
histsize=1000
ssh_client=192.168.7.105 50641 22
Selinux_use_current_range=
qtdir=/usr/lib/qt-3.3
Qtinc=/usr/lib/qt-3.3/includ
========= a lot.
The Chige of which the path is declared is:
Path= $PATH: <path 1>:<path 2>:<path 3>:------: <path n>
When the program in a directory is running, you can search for the relevant commands in the directory within the path defined in the file, so you can use the commands in the compiler. So the value of path is a series of directories, and when you run a program, Linux searches under these directories to set the value of the path under the command.
Direct with export command
Add the/data/test/hellow.sh script to the path so that the script can be executed in a different directory.
[Root@localhost/]# Cd/data/test
[Root@localhost test]# LL
Total Dosage 4
-RWX------1 root 32 October 13:02 hellow.sh
[Root@localhost test]# echo $PATH #显示 $PATH variable
This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/x11r6/ Bin:/root/bin
[Root@localhost test]# CD/
[Root@localhost/]# Export path=/data/test: Add script path $PATH #在 $PATH
[root@localhost/]# export|grep test #查看 $PATH
Declare-x oldpwd= "/data/test"
Declare-x path= "/data/test:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/ Sbin:/usr/bin:/usr/x11r6/bin:/root/bin "
Modify Profile
[Root@localhost/]# Vi/etc/profile
Export PATH USER LOGNAME MAIL HOSTNAME histsize inputrc #加入
Root/.bash_profile is one of the Linux three environment variable settings files, and the scope of this environment variable is only the current user
modifying. bashrc files
[Root@localhost/]# VI/ROOT/.BASHRC
#. BASHRC
# User specific aliases and functions
Alias Rm=rm-i
Alias Cp=cp-i
Alias Mv=mv-i
# Source Global Definitions
if [-F/ETC/BASHRC]; Then
. /etc/bashrc
Fi
Export path= "$PATH:/data/test/"
Modify the environment variable by modifying the environment variable definition file.
It should be noted that, in general, this applies only to ordinary users, avoiding the modification of the root user's environment definition file, which can pose a potential risk.
--------------------------------------------------------------------------------
$CD #到用户根目录下
$ls-A # View all files, including hidden files
$vi. Bash_profile # Modify the environment variable definition file
--------------------------------------------------------------------------------
Then edit your PATH declaration in the format:
Path= $PATH: <path 1>:<path 2>:<path 3>:------: <path n>
You can add the specified path yourself, separated by a colon in the middle. When the environment variable is changed, it will take effect the next time the user logs on, and if you want to take effect immediately, you can execute the following statement: $ source. bash_profile