DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I setup tomcat and I set the JAVA environment variable in /etc/profile. After I restart my computer and start tomcat, it report NO JAVA environment variable was set. I echo $JAVA_HOME and there is nothing to display.
Please help me: why my setting in /etc/profile doesn't work??
i'd guess you've not exported the variable. run "export JAVAHOME=..." not just "JAVAHOME=..." as the later is only held within the scope of the profile script. so when the profile script is finished, the variable is destroyed. export pushes that variable back out to the users login shell.
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "`id -u`" -eq 0 ]; then
PATH=".:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/ X11"
else
PATH=".:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games"
fi
if [ "$PS1" ]; then
if [ "$BASH" ]; then
PS1='\u@\h:\w\$ '
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi
Did you logout since making the change. The /etc/profile script is only executed if bash called interactively as a login shell. Are you sure you are using the bash shell? Check your entry in /etc/passwd. Also check that the --nologin option isn't present.
Section 6.2 of the bash info manual details which login scripts are executed, and under which circumstances.
Did you logout since making the change. The /etc/profile script is only executed if bash called interactively as a login shell. Are you sure you are using the bash shell? Check your entry in /etc/passwd. Also check that the --nologin option isn't present.
Section 6.2 of the bash info manual details which login scripts are executed, and under which circumstances.
By the way, should the global evironment variables relate to the terminal type? I think they may not be related.
Try them in your ~/.bashrc then that should be getting executed on login just make sure this is set in your ~/.bash_profile.
Code:
# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
No need to logout and back in for testing just use source ~/.bashrc to re-read the file in the current shell once everything is set then logout and back in.
Does tomcat run as a system user. If that is the case, you wouldn't set ~/.bashr or ~/.profile as a system user doesn't have a home directory. Also, it might be running in a jail. That means that the environment may be cleared out. If you have an /etc/profile.d/ directory, then put your "export
This link may help: http://www-128.ibm.com/developerwork...xw16TomcatCage
On some systems, there is an /etc/profile.d/ directory where you can add system wide shell startup scripts, such as a /etc/profile.d/tomcat.sh script. However, given your /etc/profile script, it doesn't appear to be the case.
I didn't notice a tomcat system user or a regular user in your /etc/passwd file. This may be a RTFM situation where you need to read through the tomcat installaton procedures more carefully.
Try them in your ~/.bashrc then that should be getting executed on login just make sure this is set in your ~/.bash_profile.
Code:
# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
No need to logout and back in for testing just use source ~/.bashrc to re-read the file in the current shell once everything is set then logout and back in.
Thank you. What you say is correct. But I let my tomcat auto-run. So, I need set the global environment variables to support it. When tomcat auto-run, the terminate's environment variables isn't initialized. This is mean the .bashrc environment work after tomcat auto-run, so tomcat can't find the evironment variables.
Does tomcat run as a system user. If that is the case, you wouldn't set ~/.bashr or ~/.profile as a system user doesn't have a home directory. Also, it might be running in a jail. That means that the environment may be cleared out. If you have an /etc/profile.d/ directory, then put your "export
This link may help: http://www-128.ibm.com/developerwork...xw16TomcatCage
On some systems, there is an /etc/profile.d/ directory where you can add system wide shell startup scripts, such as a /etc/profile.d/tomcat.sh script. However, given your /etc/profile script, it doesn't appear to be the case.
I didn't notice a tomcat system user or a regular user in your /etc/passwd file. This may be a RTFM situation where you need to read through the tomcat installaton procedures more carefully.
I use j2sdk for other applications besides tomcat. So I want to set global environment. But after I edit the /etc/profile and restart my computer, the java global environment doesn't work. I use 'echo $JAVA_HOME', there is nothing to display too. That confused me.
Well if everything else is not working then try putting the lines in the file /etc/init.d/bootmisc.sh near the bottom of the file above the exit 0, that is pretty much the last file run before the login happens. If needed sooner due to start up of the Tomcat make a file and put it in the /etc/init.d/ directory and make a symbolic link into the /etc/rc2.d/ directory with a number lower than the one that starts the Tomcat.
Well if everything else is not working then try putting the lines in the file /etc/init.d/bootmisc.sh near the bottom of the file above the exit 0, that is pretty much the last file run before the login happens. If needed sooner due to start up of the Tomcat make a file and put it in the /etc/init.d/ directory and make a symbolic link into the /etc/rc2.d/ directory with a number lower than the one that starts the Tomcat.
Thank you agian. Well, I give it up. My solution is add the JAVA environment variables to every header of applications startup shell script which use j2sdk.
It will be a puzzle that the /etc/profile doesn't work.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.