I am running CentOS 6.6 on VmWare Player. I have added path
export CLASSPATH=$CLASSPATH:<path/to/jars>
of the required jar files to .bash_profile which resides in my home folder.
Also on executing the following command:
gvanjoic@localhost$ echo $CLASSPATH
It displays the classpath as expected. But, there are some tasks that I need to run as root user. So on running the following commands, the output is not as expected.
gvanjoic@localhost: su
Password:
root@localhost gvanjoic$ echo $CLASSPATH
Output
.
Consequently, I can't execute the tasks. What am I possibly doing wrong here. Help appreciated.
FYI, gvanjoic is not in sudoers list.
The .bashrc
in your homefolder is only executed for your user.
Thus when logging in as root, it's not being executed, and root gets a "clean" shell. You probably want to put these lines into /etc/profile
if they're valid for the whole system, and not just for your user.
Also try "su -" as the "-" indicates that when you change users, .bashrc should be exported
from "man su"
-, -l, --login
Provide an environment similar to what the user would expect had the user logged in directly.
When - is used, it must be specified as the last su option. The other forms (-l and --login) do not have this
restriction.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.