Solved

export CLASSPATH for all users Linux Centos 5.9

Posted on 2014-01-15
5
1,126 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 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

1. Introduction As many people are interested in Linux but not as many are interested or knowledgeable (enough) to install Linux on their system, here is a safe way to try out Linux on your existing (Windows) system. The idea is that you insta…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

732 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