linux系统变量
expert WORKDIR expert 命令可以将变量提升为全局变量,但是重启服务之后会消失。
如果全局变量要求重启之后能永久使用。可以写入到shell启动时会读取的脚本中。
/etc/profile $HOME/.bash_profile $HOME/.bashrc $HOME/.bash_login $HOME/.profile /etc/profile 是默认的主启动文件,每一个用户登录都会执行这个文件。 另外四个文件都是对应的用户登录时才可能会执行。因为只会运行第一个找到的文件,其余的会被忽略。
/etc/profile 文件是去遍历 /etc/profile.d/*.sh 然后执行所有的脚本,遍历逻辑如下(从ubuntu发行版 /etc/profile 文件中复制)
if [ -d /etc/profile.d ]; then for i in /etc/profile.d/*.sh; do if [ -r $i ]; then . $i # . 等同于 source 即激活shell脚本 fi done unset i fi
unset WORKDIR 取消变量。
欺骗自己最简单,欺骗自己最困难。
安慰自己最简单,安慰自己最困难。