Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

export CLASSPATH for all users Linux Centos 5.9

Posted on 2014-01-15
5
1,095 Views
Last Modified: 2014-01-15
Hi,

I read here:

that to export CLASSPATH for all users I would set it in /etc/profile. So I have this:

export JAVA_HOME=/usr/bin/java:/usr/local/jdk
export PATH=$PATH:/usr/local/jdk/bin:/usr/local/jdk/bin:/home/ultratrust/perl5/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/home/ultratrust/bin:/usr/local/bin:/usr/X11R6/bin
export CLASSPATH=.:$CLASSPATH:/home/myultrat/ssl/paypal/java/lib

Open in new window


But when I logout/login I get this:
 echo $CLASSPATH
.:/usr/local/jdk/lib/classes.zip

If I run:
source /etc/profile

then I get:
 echo $CLASSPATH
.:.:/usr/local/jdk/lib/classes.zip:/home/myultrat/ssl/paypal/java/lib

So why doesn't the CLASSPATH echo what's in /etc/profile if I logout/login?

I login in as su (root).
0
Comment
Question by:Victor Kimura
  • 2
  • 2
5 Comments
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 500 total points
ID: 39781901
I assume that you have your own ~/.bashrc file which supersedes the setting in /etc/profile.

Besides that, "su" alone without the following "-" ("su - root") doesn't run a login shell, so your environment (the one of the user you're su'ing from) does not change.
0
 
LVL 31

Expert Comment

by:farzanj
ID: 39782252
For bash use your account's file

~/.bash_profile

file.
0
 

Author Comment

by:Victor Kimura
ID: 39783660
@woomilkporc, I have this in my ~/.bashrc:

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

Open in new window


Also, when I use su - root I get an error:

su -root
su: invalid option -- r

-----
@farzanj, that command you suggested:
~/.bash_profile

Isn't that only for a single user? I'm trying to create the PATH for all users.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39783735
The dash must be surrounded by spaces

su - root

As for bashrc - you .bashrc tries to source a file /etc/bashrc which could be the culprit.
Check if this file exists and if so examine it for "CLASSPATH"!

~/.bash_profile as well as ~/.bashrc are user-specific, but settings in each of both files override the ones made in /etc/profile.

If "su - root" doesn't yield the expected result check root's initialization files  ~/.bash_profile and ~/.bashrc for CLASSPATH, and check if root's .bashrc also tries to source /etc/bashrc.
0
 

Author Comment

by:Victor Kimura
ID: 39783835
Ok. Thanks, @woolmilkporc!

I found the PATHs are found in /etc/bashrc.

I have this in that file:

export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/classes.zip:/home/myultrat/ssl/paypal/java/lib
export PATH="$PATH:/usr/local/bin:/usr/X11R6/bin"

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question