Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

export CLASSPATH for all users Linux Centos 5.9

Posted on 2014-01-15
5
Medium Priority
?
1,177 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
[X]
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
  • 2
  • 2
5 Comments
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 2000 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 2000 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

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

715 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