LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-26-2008, 01:54 PM   #1
dralexpe
LQ Newbie
 
Registered: Jun 2007
Posts: 27

Rep: Reputation: 15
Unhappy Cannot correctly set up the PATH environment variable Centos


I am having troubles with the PATH environment variable. A while ago I installed Java on my system and now I have removed it and I am trying to reinstall. Now the java issue is a separate thing, I would like some help with the environment variables.

I am running Centos 5 x86_64 as shown below:

Code:
[dralexpe@new-screamer ~]$ uname -a
Linux new-screamer.localdomain 2.6.18-53.1.14.el5 #1 SMP Wed Mar 5 11:37:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux
I changed the .bash_profile to add the path to the java installation, and to set up the JAVA_HOME variable as follows:
Code:
[dralexpe@new-screamer ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
PATH=$HOME/32bit_applications/usr/java/jdk1.6.0_03/bin:$PATH
export PATH

JAVA_HOME=$HOME/32bit_applications/usr/java/jdk1.6.0_03
export JAVA_HOME
dmesg > boot.msg
[dralexpe@new-screamer ~]$

I log out and log back in and the environment is still unchanged from what it was before as shown below:

Code:
[dralexpe@new-screamer ~]$ env
KDE_MULTIHEAD=false
SSH_AGENT_PID=4607
HOSTNAME=new-screamer.localdomain
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
KDE_NO_IPV6=1
GS_LIB=/home/dralexpe/.fonts
WINDOWID=44040199
QTDIR=/usr/lib64/qt-3.3
QTINC=/usr/lib64/qt-3.3/include
KDE_FULL_SESSION=true
JRE_HOME=/usr/java/jdk1.6.0_03/jre/
USER=dralexpe
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh         =00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jp         g=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
SSH_AUTH_SOCK=/tmp/ssh-pSSuei4540/agent.4540
KDEDIR=/usr
SESSION_MANAGER=local/new-screamer.localdomain:/tmp/.ICE-unix/4673
USERNAME=dralexpe
XDG_CONFIG_DIRS=/etc/kde/xdg:/etc/xdg
KONSOLE_DCOP=DCOPRef(konsole-5538,konsole)
MAIL=/var/spool/mail/dralexpe
DESKTOP_SESSION=kde
PATH=/usr/java/jdk1.6.0_03/bin:/home/dralexpe/32bit_applications/usr/java/jdk1.6.0_03/bin:/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/java/jdk1.6.0_03/bin:/usr/local/bin:/usr/bin:/bin:         /usr/X11R6/bin
GDM_XSERVER_LOCATION=local
KONSOLE_DCOP_SESSION=DCOPRef(konsole-5538,session-1)
INPUTRC=/etc/inputrc
PWD=/home/dralexpe
JAVA_HOME=/usr/java/jdk1.6.0_03
XMODIFIERS=@im=none
KDE_IS_PRELINKED=1
LANG=en_US.UTF-8
GDMSESSION=kde
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HOME=/home/dralexpe
SHLVL=3
LOGNAME=dralexpe
QTLIB=/usr/lib64/qt-3.3/lib
CVS_RSH=ssh
CLASSPATH=.
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-1WP0aURxmJ,guid=3aef3a48f58d789efb8f2d4c86993a00
LESSOPEN=|/usr/bin/lesspipe.sh %s
DISPLAY=:0
G_BROKEN_FILENAMES=1
COLORTERM=
XAUTHORITY=/tmp/.gdmBLHQBU
_=/usr/bin/env
[dralexpe@new-screamer ~]$
The path has been added, but there is the old path to the java installation which comes first, and which I am not able to remove from the PATH. Also, the JAVA_HOME is not changed also.

Do I need to make a separate script which should be called by .bash_profile?

Thanks.
Alex
 
Old 05-26-2008, 06:49 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,361

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
I seem to remember seeing an issue like this a while ago. Turned out that if you have any xterms open (via the GUI), then it caches the settings you've got and applies them to any new terms you open.
You have to completely logout of all sessions and the GUI.

Iirc, you can test alterations by doing

source .bash_profile
OR
. .bash_profile
OR
create new shell by invoking
bash

HTH
 
Old 05-26-2008, 07:46 PM   #3
dralexpe
LQ Newbie
 
Registered: Jun 2007
Posts: 27

Original Poster
Rep: Reputation: 15
I tried to log into a failsafe terminal session, but I still had to run source .bash_profile to get the environment to show the changes.

I guess what I am trying to ask is where should I change the system wide settings such that the PATH is the one I want? Also how can I get rid of some entries in the PATH, such as /usr/java/jdk1.6.0_03/bin?

I know I can do it with shell commands, but I don't want to do this every time I open a shell in the GUI (in my case that's KDE).

Thanks.
Alex
 
Old 05-27-2008, 12:48 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,361

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
You did the right thing originally, you just have to decide if you want ALL users to get the same settings, in which case the file is
/etc/profile
(edit as root)
or just individuals eg yourself, in which case its
$HOME/.bash_profile
 
Old 05-27-2008, 07:23 PM   #5
dralexpe
LQ Newbie
 
Registered: Jun 2007
Posts: 27

Original Poster
Rep: Reputation: 15
I am trying to setup the PATH just for myself, not for all users. The problem that I am having is that the old java path, in my case /usr/java/jdk1.6.0_03/bin, is still in the PATH, and even in duplicate and I don't know how to remove it.

Here is the .bash_profile which I had created:

Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
dmesg > boot.msg
#write the PATH before doing anything
echo $PATH > $HOME/pathval.txt
PATH=$(echo $PATH | sed -e 's/\/usr\/java\/jdk1.6.0_03\/bin://g')
export PATH
#write the PATH after doing the removal of entries
echo $PATH >> $HOME/pathval.txt
The way I see it, the PATH variable should match the second entry in the pathval.txt file, but it isn't. Somehow the java path is added back after the .bash_profile is run. Here is what I got:

Code:
[dralexpe@new-screamer ~]$ cat pathval.txt
/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/java/jdk1.6.0_03/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin
/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin
[dralexpe@new-screamer ~]$
[dralexpe@new-screamer ~]$
[dralexpe@new-screamer ~]$
[dralexpe@new-screamer ~]$
[dralexpe@new-screamer ~]$
[dralexpe@new-screamer ~]$ echo $PATH
/usr/java/jdk1.6.0_03/bin:/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin
[dralexpe@new-screamer ~]$
Where else should I be looking?

Thanks.
Alex
 
Old 05-28-2008, 02:21 AM   #6
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Try
Code:
 strace -f -o ~/log -s 1024 -x bash -l
. Maybe it will show (strace output will be in log in your home directory, change the name if you have such file already) what files get read and where does it reads the content of JAVA_HOME at all.
 
Old 05-30-2008, 05:41 PM   #7
dralexpe
LQ Newbie
 
Registered: Jun 2007
Posts: 27

Original Poster
Rep: Reputation: 15
Well, I tried strace but the output was not comprehensible for my knowledge and it was also too long to be allowed to post here.

Anyways, it turned that there was a script /etc/profile.d/java.sh which was setting all the environment variables for java, namely JRE_HOME, JAVA_HOME, CLASSPATH then added JAVA_HOME to the PATH.

I disabled those lines in the script and the problem was solved.

I would like to thank a lot to all of you for all your help.
 
Old 05-30-2008, 11:23 PM   #8
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
Well, that is close top what I hoped for - strace was proposed for finding a script that mentions unwanted values of variables. Nice to hear that problem is solved.

By the way (if it will ever be useful, and it may be), there are some nice ways to share a huge chunk of text in a forum. You could check if pastebin.org (or some similar service, there are a few) accepts such amounts of data (which is not entirely unlikely). You could sign up for a free hosting and create one page with <pre> tag and all the needed data; please, use random name not to deprive anyone with a more elaborate site idea of the namespace. Also registering a fresh GMail/Yahoo! Mail, sending the file to yourself and sharing the login and password here (there is only message in the inbox/outbox, as it is a fresh account that should be abandoned afterwise) works.
 
  


Reply



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
PATH environment variable moonz Red Hat 3 09-08-2005 04:10 PM
changing path environment variable iNET_boss Linux - Newbie 2 07-27-2005 04:35 PM
Modifying the PATH environment variable brunnopessoa Linux - Newbie 11 11-03-2004 10:23 PM
How to set PATH How do I set PATH environment variable? Tranquil Linux - Newbie 3 11-02-2003 02:52 AM
how do I edit the $PATH environment variable in RH7.3 needamiracle Linux - Software 3 07-02-2002 09:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:18 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