我想使用环境变量来保存值,重启系统后,此变量必须包含最后保存的值
我试试这个
root@OpenWrt:~# BOOTT=1
root@OpenWrt:~# export
export HOME='/root'
export LOGNAME='root'
export PATH='/bin:/sbin:/usr/bin:/usr/sbin'
export PS1='\u@\h:\w\$ '
export PWD='/root'
export SHELL='/bin/ash'
export SSH_CONNECTION='192.168.1.110 2961 192.168.1.122 22'
export SSH_TTY='/dev/pts/0'
export TERM='xterm'
export USER='root'
root@OpenWrt:~# export BOOTT
root@OpenWrt:~# export
export BOOTT='1'
export HOME='/root'
export LOGNAME='root'
export PATH='/bin:/sbin:/usr/bin:/usr/sbin'
export PS1='\u@\h:\w\$ '
export PWD='/root'
export SHELL='/bin/ash'
export SSH_CONNECTION='192.168.1.110 2961 192.168.1.122 22'
export SSH_TTY='/dev/pts/0'
export TERM='xterm'
export USER='root'
root@OpenWrt:~#
root@OpenWrt:~# reboot
root@OpenWrt:~#
==>重启后
root@OpenWrt:~# export
export HOME='/root'
export LOGNAME='root'
export PATH='/bin:/sbin:/usr/bin:/usr/sbin'
export PS1='\u@\h:\w\$ '
export PWD='/root'
export SHELL='/bin/ash'
export SSH_CONNECTION='192.168.1.110 3217 192.168.1.122 22'
export SSH_TTY='/dev/pts/0'
export TERM='xterm'
export USER='root'
root@OpenWrt:~# echo $BOOTT
root@OpenWrt:~#
所以我可以获得env变量,它可以在重启后保存值!!
答案 0 :(得分:2)
或者,如果您想要全局制作这些变量,请将它们放在/ etc / profile中,并将此文件源于每个用户的.bashrc。
答案 1 :(得分:1)
将以下内容添加到$HOME/.profile
:
BOOTT=1
export BOOTT