Solved

export CLASSPATH for all users Linux Centos 5.9

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Suggested Courses

627 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