Solved

export CLASSPATH for all users Linux Centos 5.9

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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:

747 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now