Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create a new environment variable in linux [openwrt]

I want to use environment variable to save value and after reboot the system, this variable must contain the last value saved
I try this

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:~#

==> after reboot

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:~#

so can I obtain env variable which can saved value after reboot !!

like image 318
stack_A Avatar asked Feb 16 '26 09:02

stack_A


2 Answers

Add the following to your $HOME/.profile:

BOOTT=1
export BOOTT
like image 184
devnull Avatar answered Feb 18 '26 01:02

devnull


Or if you want to make those variables globally, put them in /etc/profile and source this file in .bashrc of each user.

like image 24
podwysoc Avatar answered Feb 18 '26 02:02

podwysoc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!