LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   no value for environment variable when reboot pc (https://www.linuxquestions.org/questions/linux-newbie-8/no-value-for-environment-variable-when-reboot-pc-4175592939/)

luofeiyu 11-05-2016 03:07 AM

no value for environment variable when reboot pc
 
I have added a line in /etc/profile
Code:

    export SMARTY_DIR=/usr/local/lib/Smarty/
`echo $SMARTY_DIR` can get value `/usr/local/lib/Smarty/` after `source /etc/profile`.
When to reboot my pc ,`echo $SMARTY_DIR` can get nothing.

What is the matter for my bash configure?

grail 11-05-2016 07:23 AM

See if this link lends you some insight ;)

http://www.linuxfromscratch.org/blfs...s/profile.html

ondoho 11-05-2016 12:50 PM

Quote:

Originally Posted by luofeiyu (Post 5627176)
`echo $SMARTY_DIR` can get value `/usr/local/lib/Smarty/` after `source /etc/profile`.
When to reboot my pc ,`echo $SMARTY_DIR` can get nothing.

which distro, which bash version?
as which user are you sourcing /etc/profile, and echoing the variable?
is /etc/profile sourced during boot?

luofeiyu 11-15-2016 06:51 PM

debian8 is the normal account name.

debian8@hwy:~$ bash --version
GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
debian8@hwy:~$ uname -a
Linux hwy 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux
debian8@hwy:~$ source /etc/profile
debian8@hwy:~$ echo $SMARTY_DIR
/usr/local/lib/Smarty/
`/etc/profile` not sourced during boot.

After reboot and input echo $SMARTY_DIR on account name ----debian8,nothing get.

Keith Hedger 11-15-2016 06:58 PM

just add it to ~/.bashrc

luofeiyu 11-15-2016 08:58 PM

I got the answer in http://unix.stackexchange.com/questi...on-login-shell

A shell started in a new terminal in a GUI would be an interactive non-login shell. It would source your .bashrc, but not your .profile, for example.

It is the best way to add the following line both in /etc/profile(for login shell) and /etc/bash.bashrc(for non-login shell) for my debian.

Code:

export SMARTY_DIR=/usr/local/lib/Smarty/

Keith Hedger 11-16-2016 04:07 AM

the files in /etc are really for global/root use though they can of course be used by any user, you are much better using the corresponding files in your home folder


All times are GMT -5. The time now is 03:00 AM.