LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-05-2016, 03:07 AM   #1
luofeiyu
Member
 
Registered: Aug 2015
Posts: 220

Rep: Reputation: Disabled
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?
 
Old 11-05-2016, 07:23 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,719

Rep: Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034
See if this link lends you some insight

http://www.linuxfromscratch.org/blfs...s/profile.html
 
Old 11-05-2016, 12:50 PM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 12,306
Blog Entries: 9

Rep: Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309Reputation: 3309
Quote:
Originally Posted by luofeiyu View Post
`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?
 
Old 11-15-2016, 06:51 PM   #4
luofeiyu
Member
 
Registered: Aug 2015
Posts: 220

Original Poster
Rep: Reputation: Disabled
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.
 
Old 11-15-2016, 06:58 PM   #5
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,703

Rep: Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678
just add it to ~/.bashrc
 
Old 11-15-2016, 08:58 PM   #6
luofeiyu
Member
 
Registered: Aug 2015
Posts: 220

Original Poster
Rep: Reputation: Disabled
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/

Last edited by luofeiyu; 11-16-2016 at 08:08 PM.
 
Old 11-16-2016, 04:07 AM   #7
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,703

Rep: Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678Reputation: 678
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Environment variable that dynamically changes when another variable is changed youtoo Linux - Newbie 4 02-17-2016 01:44 AM
Environment Variable khdani Linux - Newbie 1 10-05-2008 10:14 AM
Environment variable.. manomohan Programming 1 02-26-2007 11:27 PM
environment variable gamor Linux - Newbie 4 04-30-2005 05:28 PM
environment variable mimi Linux - Newbie 1 04-10-2002 08:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration