A configuration file /etc/profilethat specifies the environment variables, which represent system-related environment variables
Note : But to change certain environment variables, it's best to define and write your own shell under/etc/profile.d/.
It is best not to change the/etc/profile file.
Like defining a path.sh.
[Email protected] ~]# vim/etc/profile.d/path.sh
#!/bin/bash
Export path= $PATH:/tmp/:/data/bin/#自己新定义的PATH
Reset and take effect
[Email protected] ~]# Source/etc/profile
[Email protected] ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/tmp/:/data/bin/
Another configuration file /ETC/BASHRC, will be defined Ps1,umask (/etc/profile file is also defined)
Note : This file is best not to be modified; it's better to define it under/etc/profile.d/and write your own shell.
View PS1
[Email protected] ~]# echo $PS 1 #PS1定义的我们命令的前缀
[\[email protected]\h \w]\$
Change the PS1, replace W to W, the difference is that W will show the absolute path, and W will show the last segment of the path
[[email protected] ~]# ps1= ' [\[email protected]\h \w]\$ '
[Email protected] ~]# cd/etc/init.d/
[Email protected] /ETC/INIT.D]#
[[email protected]/etc/init.d]# ps1= ' [\[email protected]\h \W]\$ '
[Email protected] init.d]# cd/etc/init.d/
[Email protected] INIT.D]#
You can also add time \ t
[[email protected] init.d]# ps1= ' [\[email protected]\h\ t \w]\$ '
[Email protected]19:29:31 init.d]#
Root user is # Normal user is $
[Email protected] ~]# Su-wyy
[Email protected] ~]$
/etc/profile,/ETC/BASHRC is about the system level. In addition to these two, there are some in the user's home directory, you can use Ls-la.
You can see a few that start with. Bash. The . Bash_profile file and our system's/etc/profile file are a class of files, much like. /etc/profile
A configuration file that can be used by any user, and if you want to define some environment variables for the user, you can
. Bash_profile to define.
. BASHRC This defines the user's alias, which is executed when the user logs on and every time a new shell is opened.
Note : . BASHRC will be called by. Bash_profile
If you define a variable in the. BASHRC and then unset the variable in. Bash_profile, then when we log in to a terminal, echo the value of the variable is empty
This article from the "Linux" blog, reproduced please contact the author!
environment variable profiles for systems and users