SlackwareThis Forum is for the discussion of Slackware 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 started off teaching myself linux using RedHat 9.0 and became familiar using Tomcat and Postgres to run a web-based employment system for a school project. I have since moved on to Slackware (If Nautilus crashed one more time, I was going to hurt someone) and found it to be much more enjoyable than DeadRat. But I have just one little problem. I have installed both Tomcat and Postgres successfully on Slackware, but I am having troubles using my environmental variables. Here is a what my /etc/profile looks like:
# /etc/profile: This file contains system-wide defaults used by
# all Bourne (and related) shells.
# Set the values for some environment variables:
export MINICOM="-c on"
export MANPATH=/usr/local/man:/usr/man:/usr/X11R6/man
export HOSTNAME="`cat /etc/HOSTNAME`"
export LESSOPEN="|lesspipe.sh %s"
export LESS="-M"
# If the user doesn't have a .inputrc, use the one in /etc.
if [ ! -r "$HOME/.inputrc" ]; then
export INPUTRC=/etc/inputrc
fi
# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games"
# For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in
# the $PATH. Some means of connection don't add these by default (sshd comes
# to mind).
if [ "`id -u`" = "0" ]; then
echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
if [ ! $? = 0 ]; then
PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
fi
fi
# I had problems using 'eval tset' instead of 'TERM=', but you might want to
# try it anyway. I think with the right /etc/termcap it would work great.
# eval `tset -sQ "$TERM"`
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
TERM=linux
fi
# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
VISUAL=emacs
# VISUAL=gmacs
# VISUAL=vi
fi
# Set a default shell prompt:
#PS1='`hostname`:`pwd`# '
if [ "$SHELL" = "/bin/pdksh" ]; then
PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
PS1='! ${PWD/#$HOME/~}$ '
elif [ "$SHELL" = "/bin/zsh" ]; then
PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
PS1='$ '
else
PS1='\u@\h:\w\$ '
fi
PS2='> '
export PATH DISPLAY LESS TERM PS1 PS2
# Default umask. A umask of 022 prevents new files from being created group
# and world writable.
umask 022
# Set up the LS_COLORS and LS_OPTIONS environment variables for color ls:
if [ "$SHELL" = "/bin/zsh" ]; then
eval `dircolors -z`
elif [ "$SHELL" = "/bin/ash" ]; then
eval `dircolors -s`
else
eval `dircolors -b`
fi
# Notify user of incoming mail. This can be overridden in the user's
# local startup file (~/.bash.login or whatever, depending on the shell)
if [ -x /usr/bin/biff ]; then
biff y
fi
# Append any additional sh scripts found in /etc/profile.d/:
for profile_script in /etc/profile.d/*.sh ; do
if [ -x $profile_script ]; then
. $profile_script
fi
done
unset profile_script
# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
PATH="$PATH:."
fi
The variables I am most conerned with are the ones listed just above here. I have added these variables by editing /etc/profile as root (since this is my only privileged user). I have since created two new users "Tim" and "postgres". PostGreSQL requires it's own user to run the daemon and needs access to the PGDATA and JAVA_HOME variables. However, when I log in to the system as "Tim" and then "su" to "postgres" to start the PostGreSQL daemon, the variables are not available to me. In fact, not even the $PATH variable is the same (it is missing the appended directories above). But if I log in as root and "su" to "Tim" or "postgres" then all of the environmental variables are set properly.
This is something I did not encounter using RedHat 9.0 since I only had to edit the /etc/profile using root and then all variables were accessible by all users even if I didn't log in as root first.
Any help is greatly appreciated. I have rather enjoyed learning to use Linux and find myself spending more time using my Linux machine than I do my three other windows machines.
ah, ok. Well, I tried that as well and I didn't know the password for "postgres" so I created a new one for it. Though whenever I am logged in under my user and do the "su postgres" the variables still aren't there.
When I log in as my user and do "su postgres", echo $PATH returns /usr/local/bin etcetera but it doesn't contain the additional ${ANT_HOME}/bin.
I was typing "su postgres". If I type "su -postgres" I get "sorry" even if I put in the correct password. However, if I log in to the system as the user "postgres" then all of the environmental variables work fine. What is the significance of the "-" before the username when using "su"?
"su postgres -" let's me switch to the user "postgres" but the variables still aren't coming through. $PATH does not contain the appended directories listed in /etc/profile. However, they do exist for the user "Tim" which I log in as.
All source /etc/profile , does is that i reads the /etc/profile as the curretn user & initialises / sets the appropriate environment variables. Since you're not seeing the environment variables as postgres, you should type source /etc/profile when you're logged on as postgres. If you get the variables to appear then you should add source /etc/profile to your .bashrc in the home directory of postgres.
To add it to your home directory log on as postgres & type echo source /etc/profile >>.bashrc & hopefully it should 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.