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 02-26-2003, 09:26 AM   #1
zulu1_hl
LQ Newbie
 
Registered: Aug 2002
Posts: 7

Rep: Reputation: 0
Question modifying environment variables


Hi,

I am trying to modify the environment variables permanently.

From what I can gather from some research (it's been tough finding some definitive How-To's), modifying the .bash_profile will set the variables only for that user, whereas modifying the /etc/profile will set that change globally--is this correct?

If so, how do I formulate the syntax? I am trying to set the jdk.../bin path permanently.

Thanks.
 
Old 02-26-2003, 09:34 AM   #2
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
The /etc/bashrc is used for

# System wide functions and aliases

and the /etc/profile is used for

# System wide environment and startup programs, for login setup

So if you want all users to have jdk in there path then you could add this line to your /etc/profile:

export PATH=$PATH:/path/to/jdk
 
Old 02-26-2003, 10:00 AM   #3
zulu1_hl
LQ Newbie
 
Registered: Aug 2002
Posts: 7

Original Poster
Rep: Reputation: 0
Smile

Thanks Carshed

Will give it a try.
 
Old 02-26-2003, 10:15 AM   #4
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
Do or do not. There is no try.
 
Old 02-26-2003, 10:25 AM   #5
zulu1_hl
LQ Newbie
 
Registered: Aug 2002
Posts: 7

Original Poster
Rep: Reputation: 0
Smile Found Another Solution

Found this solution after some more research:

To set the the path globally:

-goto the /etc/profile.d
-create a new file called java.sh
-in the java.sh, set the following:

#!/bin/bash
export JAVA_HOME=/usr/java/jdk1.3.1_07
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.

This worked. Since I had a hard time trying to figure out where to set that in my /etc/profile to make it work properly. This is my /etc/profile:

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|$1($|" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}

# Path manipulation
if [ `id -u` = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi

pathmunge /usr/X11R6/bin after

unset pathmunge

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi


export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done

unset i
 
Old 02-26-2003, 10:33 AM   #6
Crashed_Again
Senior Member
 
Registered: Dec 2002
Location: Atlantic City, NJ
Distribution: Ubuntu & Arch
Posts: 3,503

Rep: Reputation: 57
Oh okay. Well for future use you can just add those lines to the end of the /etc/profile file.

# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|$1($|" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}

# Path manipulation
if [ `id -u` = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi

pathmunge /usr/X11R6/bin after

unset pathmunge

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi


export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done

unset i

export PATH=$PATH:/path/to/jdk
 
  


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
Modifying DISPLAY environment variable on-the-fly ktulu1115 Linux - Software 1 10-07-2005 02:18 PM
environment variables naren Linux - Software 1 12-15-2004 06:44 AM
Modifying the PATH environment variable brunnopessoa Linux - Newbie 11 11-03-2004 10:23 PM
environment variables kakridge Linux - Newbie 1 07-14-2003 06:25 PM
environment variables aethereal Linux - Newbie 7 12-19-2001 09:34 AM

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

All times are GMT -5. The time now is 01:35 AM.

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
Open Source Consulting | Domain Registration