定义自定义环境变量:(使用export和declare)
针对root用户的所有连接:root_data=root
针对所有用户的变量: all_data=all
添加
[root@node1 ~]# vim /etc/profile
ROOT_DATA="ROOT"
export ROOT_DATA
[root@node1 ~]# vim .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
ALL_DATA="ALL"
export ALL_DATA
~
~
读取shell程序文件
[root@node1 ~]# source ~/.bash_profile
[root@node1 ~]# source /etc/profile
[root@node1 ~]# echo $ALL_DATA
ALL
[root@node1 ~]# env | grep ROOT
ROOT_DATA=ROOT
[root@node1 ~]#