LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Add to PATH (bash) for All Users (Suse) (https://www.linuxquestions.org/questions/linux-newbie-8/add-to-path-bash-for-all-users-suse-663217/)

davidstvz 08-16-2008 10:00 AM

Add to PATH (bash) for All Users (Suse)
 
I tried looking this one up on the net and am so far confused. I will continue looking.

In particular, I just installed the jdk-6u7 rpm, but the path is still pointing to the old 1.4.2 (at least when I run java -version) it still tells me that version number.

I want to find where the path info is for that and fix it.

davidstvz 08-16-2008 10:09 AM

By the way, I should add that there is no /etc/profile file there is an /etc/profile.d directory

Err... I take that back. Maybe I mistyped the word last time. I probably got this now. Sorry to junk up the page with another post.

EDIT:

Great... a new problem. I have automatic updates configured, but this file as marked as a "do not change" because updates may overwrite it. But how else can I set the path permanently for all users on the system?

bhaslinux 08-16-2008 10:11 AM

The path gets set in system profile file
to know where the path is set, may be long, but u can use

bash -x

to trace through the commands and find out where the path is being set.
This is for bash shell only and in case of other shells appropriate command must be used.

davidstvz 08-16-2008 10:14 AM

Quote:

Originally Posted by bhaslinux (Post 3249692)
The path gets set in system profile file
to know where the path is set, may be long, but u can use

bash -x

to trace through the commands and find out where the path is being set.
This is for bash shell only and in case of other shells appropriate command must be used.

ACK

I just tried to dump that in a file using

bash -x > zpath.txt

and now everythign is acting crazy

davidstvz 08-16-2008 10:15 AM

pwd tells me I am in

+ pwd

I think it's letting me add things to the path but it looks like I'm at a prompt.

davidstvz 08-16-2008 10:17 AM

I'm not doing anything else until I understand what's going on before I break something.

EDIT

Well, I just logged out and back in. That was screwy as hell though.

So I guess I have no other options but to edit the /etc/profile file even if the Suse updater is going to kill it now and then?

davidstvz 08-16-2008 10:53 AM

I'm completely stuck here.

I can't even FIND the old Java 1.4.2 installation. And I can't find any file that specified a path to it (or any other version of Java).

I really need to get this done by Sunday night :) Your help is as always greatly appreciated!

I ran the find command on the entire system seraching for *jdk* and it tells me it didn't find anything. Then I go to /usr/java/ and search there and it finds the whole 1.6 jdk. How the hell did my system wide search for *jdk* not find the 1.6 jdk (and it should have found the 1.4.2 wherever it is).

pronoy 08-16-2008 02:03 PM

Quote:

Originally Posted by davidstvz (Post 3249697)
pwd tells me I am in

+ pwd

I think it's letting me add things to the path but it looks like I'm at a prompt.

bash -x has forked the second shell within the original one. You could have come out using 'exit' command

arizonagroovejet 08-16-2008 02:21 PM

Assuming your users have the default shell of bash, then put stuff like alterations to $PATH in to /etc/bash.bashrc.local - it doesn't exist by default but if you look at /etc/bash.bashrc it tells you not to put stuff in there and use /etc/bash.bashrc.local

davidstvz 08-16-2008 02:33 PM

Yes they're using bash. I don't see a

bash.bashrc.local

just

bash.bashrc

Ideally I'd like to find the file that currently says "java 1.4* this way" and edit it. I want to make back up of that file and restore it if anything goes wrong.

This bash.bashrc doesn't have anything like that in it. That I can find (using /java /jdk and /$PATH in vi).

arizonagroovejet 08-16-2008 02:36 PM

Quote:

Originally Posted by davidstvz (Post 3249918)
Yes they're using bash. I don't see a

bash.bashrc.local

I refer you to the part of my post where I said that it does not exist by default.

davidstvz 08-16-2008 02:43 PM

Ah yes, missed that part.

If this works, that still leaves me wondering where in blue hell java1.4.2 is installed and where the original settings for that are!

So I just put..

PATH=$PATH:/usr/java/jdk1.6.0_07/bin/

..in the file and call it a day?

davidstvz 08-16-2008 02:44 PM

Quote:

Originally Posted by davidstvz (Post 3249930)
Ah yes, missed that part.

If this works, that still leaves me wondering where in blue hell java1.4.2 is installed and where the original settings for that are!

So I just put..

PATH=$PATH:/usr/java/jdk1.6.0_07/bin/

..in the file and call it a day?

Ok, that's not working just yet.

arizonagroovejet 08-16-2008 02:52 PM

If you want people to get the java that belongs to 1.6 it needs to be in $PATH before 1.4.2. So you want

Code:

PATH=/usr/java/jdk1.6.0_07/bin/:$PATH
Except that's not the best way to do it. A better way would be to change stuff in /etc/alternatives/ to point at your desired version of java
Code:

linux-poir:~ # more /etc/issue

Welcome to SUSE Linux Enterprise Desktop 10 SP2 (i586) - Kernel \r (\l).

linux-poir:~ # ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2008-07-21 18:15 /usr/bin/java -> /etc/alternatives/java
linux-poir:~ # ls -l /etc/alternatives/java*
lrwxrwxrwx 1 root root 35 2008-07-21 18:23 /etc/alternatives/java -> /usr/lib/jvm/jre-1.4.2-sun/bin/java
lrwxrwxrwx 1 root root 44 2008-07-21 18:23 /etc/alternatives/java.1.gz -> /usr/share/man/man1/java-java-1_4_2-sun.1.gz
lrwxrwxrwx 1 root root 40 2008-07-21 18:23 /etc/alternatives/javaws -> /usr/lib/jvm/jre-1.4.2-sun/javaws/javaws
lrwxrwxrwx 1 root root 46 2008-07-21 18:23 /etc/alternatives/javaws.1.gz -> /usr/share/man/man1/javaws-java-1_4_2-sun.1.gz

Or you could try simply removing the Java 1.4.2 rpm

Code:


linux-poir:~ # rpm -qf /usr/lib/jvm/jre-1.4.2-sun/bin/java
java-1_4_2-sun-1.4.2.17-0.2

but I haven't tried that - it may well have a bunch of stuff that claims it as a dependency.

davidstvz 08-16-2008 02:58 PM

I just echoed my path, and the correct version of java is in it, but it's still going to 1.4.2 first.

Well, at least I know where java 1.4.2 is now :)

/usr/lib/jvm/jre-1.4.2-sun/bin/java

Oh **** no wonder. It has jre 1.4.2. I'm installing the jdk 1.6.0_07 not the jre.

So do I have to edit all these links in the /etc/alternatives/ folder?

davidstvz 08-16-2008 03:15 PM

I tried YaST, but it's a dependency nightmare in there.

I might try just copying all of those links to different location ... or maybe tarball and delete them.

Err, how do you move a link? I tried to copy it but it copied the link targets instead.

EDIT:

I just noticed that *everything* in this alternatives folder is java related (related to 1.4.2). I'm going to try renaming this folder.

davidstvz 08-16-2008 03:28 PM

Well, that did it :)

Pretty dirty hack really, but it's easy to fix if it broke anything.

colucix 08-16-2008 03:57 PM

You may be interested in this document from the OpenSuSE wiki. Look at the last section called "Switching between two different Java JREs or SDKs".

Regarding the PATH issue, the java executable is not in the system PATH, or better - as already pointed out by arizonagroovejet - it uses the /etc/alternatives system. However if you do
Code:

$ which java
you will notice that the java executable is found in /usr/bin and
Code:

$ ls -l /usr/bin/java
lrwxrwxrwx 1 root root 22 2007-10-15 14:58 /usr/bin/java -> /etc/alternatives/java

tells you that java is a link to the java in /etc/alternatives, which is another link to the real executable installed by the java RPM.

In a more general context, the system wide PATH environment variable in most system (OpenSuSE included) is set in /etc/profile plus the scripts in /etc/profile.d directory. If you look at the code in /etc/profile you will see the statements used to set the PATH plus the following piece of code:
Code:

#
# Source profile extensions for certain packages
#
if test -d /etc/profile.d -a -z "$PROFILEREAD" ; then
    for s in /etc/profile.d/*.sh ; do
        test -r $s && . $s
    done
    unset s
fi

this means: if /etc/profile.d exists and is a directory, for every file .sh in /etc/profile.d test if read permissions are granted and source it (that is include its code in the current shell). Usually the scripts in /etc/profile.d add one or more directory to the PATH and set other environment variables as MANPATH, LD_LIBRARY_PATH and other specific to the software which installed them.

Hope it is a little more clear, now! :)

davidstvz 08-16-2008 04:10 PM

OK, that's a lot more clear.

In suse there is a csh and an sh entry for each script in /etc/profile.d/

My students will use bash, so I guess that's the .sh entry?

colucix 08-16-2008 04:13 PM

Quote:

Originally Posted by davidstvz (Post 3249992)
My students will use bash, so I guess that's the .sh entry?

Yes. Files .csh are for C-shells (csh, tcsh).

davidstvz 08-16-2008 04:40 PM

I just set all the paths in that alljava.sh file manually (took at all the scripting and hard coded it) and moved the alternatives back were they were, and it's running 1.4.2_16 again. Should left well enough alone :)

In other words it's broken.

davidstvz 08-16-2008 04:48 PM

Here's what I put in alljava.sh

I'm going to move it into the bash.bashrc.local for now (minus the exports)

export JAVA_BINDIR=/usr/java/default/bin
export JAVA_ROOT=/usr/java/default/
export JAVA_HOME=/usr/java/default/
export JRE_HOME=/usr/java/default/jre
export JDK_HOME=/usr/java/default/
export SDK_HOME=/usr/java/default/


All times are GMT -5. The time now is 12:37 AM.