The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Operating Systems
> Linux Help
|
Set up linux environment variable or path?
Discuss Set up linux environment variable or path? in the Linux Help forum on Dev Shed. Set up linux environment variable or path? Linux Help forum discussing topics including usage, troubleshooting, modules, and distributions. Linux is an open source OS, based on UNIX.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

December 17th, 2011, 04:30 PM
|
|
Contributing User
|
|
Join Date: May 2011
Posts: 107
Time spent in forums: 13 h 8 m 18 sec
Reputation Power: 3
|
|
|
Set up linux environment variable or path?
Hi. I'm a window user and trying linux - ubuntu now.
I wonder how you set up your environment variable or path in linux?
I know how to do that in window but not sure how you do it in linux. I don't think it has like an interface to add it easily like in window?
|

December 18th, 2011, 07:02 AM
|
|
|
|
Just how and where you do this will depend upon two things, the shell the user will be using and if you wish to alter the setting/value globally or individually.
As you are using Linux I'd guess you shell may well be bash - so for individuals you could edit the .bash_profile file in the home directory of the relevant user, but you may prefer to use a .profile instead as that will also be used by bourne/korn shells (ig .bash_profile does not exist).
For global changes (that affect all users) look at the /etc/profile which will be used by all bourne-type shells.
__________________
The moon on the one hand, the dawn on the other:
The moon is my sister, the dawn is my brother.
The moon on my left and the dawn on my right.
My brother, good morning: my sister, good night.
-- Hilaire Belloc
|

December 18th, 2011, 03:34 PM
|
|
Contributing User
|
|
Join Date: May 2011
Posts: 107
Time spent in forums: 13 h 8 m 18 sec
Reputation Power: 3
|
|
Quote: | Originally Posted by SimonJM Just how and where you do this will depend upon two things, the shell the user will be using and if you wish to alter the setting/value globally or individually.
As you are using Linux I'd guess you shell may well be bash - so for individuals you could edit the .bash_profile file in the home directory of the relevant user, but you may prefer to use a .profile instead as that will also be used by bourne/korn shells (ig .bash_profile does not exist).
For global changes (that affect all users) look at the /etc/profile which will be used by all bourne-type shells. |
Hi. I can't get it to work and I don't know why.
I add this line on /home/bee/.bash_profile
export PATH=$PATH:/opt/lampp
Then I logout and log in as bee again.
Then I echo $PATH and I don't see my added path.
bee@bee-EG134AA-ABA-a1230n:~$ echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
Any idea what I did wrong? Thanks.
|

December 18th, 2011, 04:28 PM
|
|
|
|
Are you running the bash shell?
Try echo $SHELL
|

December 20th, 2011, 11:14 AM
|
|
Contributing User
|
|
Join Date: May 2011
Posts: 107
Time spent in forums: 13 h 8 m 18 sec
Reputation Power: 3
|
|
Quote: | Originally Posted by SimonJM Are you running the bash shell?
Try echo $SHELL |
Hi. I just did this. I installed ubuntu 11.10 recently. I'm still confuse why it's not working. Any idea?
bee@bee-EG134AA-ABA-a1230n:~$ echo $SHELL
/bin/bash
|

December 20th, 2011, 11:17 AM
|
|
Contributing User
|
|
Join Date: May 2011
Posts: 107
Time spent in forums: 13 h 8 m 18 sec
Reputation Power: 3
|
|
Quote: | Originally Posted by SimonJM Are you running the bash shell?
Try echo $SHELL |
There's also a .profile too but it seems it will ignore it base on it's comment where .bash_profile exists.
Any idea? Thanks.
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
|

December 20th, 2011, 11:33 AM
|
|
|
I have to admit on my little netbook I just have a .profile with my bash shell user ... Migrate the PATH stuff across to .profile, get rid of the .bash_profile and see what happens?
Also, don't logout and back in again, you can just source the file to get it to be re-read:
Note, that is dot space at the start
|

December 20th, 2011, 03:58 PM
|
|
Contributing User
|
|
Join Date: May 2011
Posts: 107
Time spent in forums: 13 h 8 m 18 sec
Reputation Power: 3
|
|
Quote: | Originally Posted by SimonJM I have to admit on my little netbook I just have a .profile with my bash shell user ... Migrate the PATH stuff across to .profile, get rid of the .bash_profile and see what happens?
Also, don't logout and back in again, you can just source the file to get it to be re-read:
Note, that is dot space at the start |
Hey thanks. I can get it to work on .profile and when I do echo it has the new path now.
I also tried to put it on /etc/profile and when I logout and login as bee then the new path is there too.
But when I su as root and echo $PATH then it doesn't have the new path. Any idea why?
|

December 21st, 2011, 05:39 AM
|
|
|
|
Not off the top of my head - I'd check the shell root uses and also what 'start-up' files (such as .profile) the root user has as that could over-write any prior changes done in the generic /etc/profile.
I would add a word of caution here as to what you put in the PATH for the root user: it is best not to place the current directory (the . character) in the PATH. Also add new paths at the ned, keeping the 'system' paths at the beginning.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|