LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 01-04-2005, 06:08 PM   #1
danglingpointer
LQ Newbie
 
Registered: Jan 2005
Location: USA
Distribution: Slackware 10
Posts: 17

Rep: Reputation: 0
Environmental Variables


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

#>>> ALL OF THESE WERE SET BY ME <<<

export JAVA_HOME="/usr/local/jdk1.5.0_01"
export ANT_HOME="/usr/local/apache-ant-1.6.2"
export PATH=${PATH}:${ANT_HOME}/bin
export PGDATA="/usr/local/pgsql/data"
export PATH=${PATH}:/usr/local/pgsql/bin
export CATALINA_HOME="/usr/local/jakarta-tomcat-5.5.4"

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.
 
Old 01-04-2005, 06:30 PM   #2
ringwraith
Senior Member
 
Registered: Sep 2003
Location: Indiana
Distribution: Slackware 14.2
Posts: 1,266

Rep: Reputation: 56
per man su have you tried "su - postgres"
 
Old 01-04-2005, 07:22 PM   #3
danglingpointer
LQ Newbie
 
Registered: Jan 2005
Location: USA
Distribution: Slackware 10
Posts: 17

Original Poster
Rep: Reputation: 0
If I use, "su postgres" while I am logged in as root it works just fine. But I don't want to be logged in as root all the time.
 
Old 01-04-2005, 08:28 PM   #4
ringwraith
Senior Member
 
Registered: Sep 2003
Location: Indiana
Distribution: Slackware 14.2
Posts: 1,266

Rep: Reputation: 56
no i mean from your user type "su - postgres"
 
Old 01-04-2005, 09:20 PM   #5
danglingpointer
LQ Newbie
 
Registered: Jan 2005
Location: USA
Distribution: Slackware 10
Posts: 17

Original Poster
Rep: Reputation: 0
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.
 
Old 01-04-2005, 09:30 PM   #6
ringwraith
Senior Member
 
Registered: Sep 2003
Location: Indiana
Distribution: Slackware 14.2
Posts: 1,266

Rep: Reputation: 56
are you typing "su postgres" or "su - postrgres"
 
Old 01-04-2005, 10:00 PM   #7
danglingpointer
LQ Newbie
 
Registered: Jan 2005
Location: USA
Distribution: Slackware 10
Posts: 17

Original Poster
Rep: Reputation: 0
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"?
 
Old 01-04-2005, 10:03 PM   #8
ringwraith
Senior Member
 
Registered: Sep 2003
Location: Indiana
Distribution: Slackware 14.2
Posts: 1,266

Rep: Reputation: 56
su - tells it to use the new environment

from man su : - make this a login shell

did you type su -postgres
or su - postgres
 
Old 01-04-2005, 10:37 PM   #9
danglingpointer
LQ Newbie
 
Registered: Jan 2005
Location: USA
Distribution: Slackware 10
Posts: 17

Original Poster
Rep: Reputation: 0
su -postgres gives me "sorry."

su - postgres gives me "/dev/tty1 operation not permitted."
 
Old 01-05-2005, 01:40 AM   #10
slaxnoob
Member
 
Registered: Apr 2004
Posts: 49

Rep: Reputation: 15
Try su postgres -
 
Old 01-05-2005, 03:41 AM   #11
danglingpointer
LQ Newbie
 
Registered: Jan 2005
Location: USA
Distribution: Slackware 10
Posts: 17

Original Poster
Rep: Reputation: 0
"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.
 
Old 01-05-2005, 05:49 AM   #12
slaxnoob
Member
 
Registered: Apr 2004
Posts: 49

Rep: Reputation: 15
Try typing source /etc/profile & if that helps you can add it to .bashrc for the user ( /home/postgres/.bashrc )
 
Old 01-05-2005, 03:20 PM   #13
danglingpointer
LQ Newbie
 
Registered: Jan 2005
Location: USA
Distribution: Slackware 10
Posts: 17

Original Poster
Rep: Reputation: 0
should I be logged in as root or postgres when I use the "source /etc/profile"?
 
Old 01-06-2005, 01:36 AM   #14
slaxnoob
Member
 
Registered: Apr 2004
Posts: 49

Rep: Reputation: 15
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Environmental variables... permanent fabianrios Fedora 2 10-20-2005 06:06 PM
environmental variables msound Programming 0 08-21-2004 08:06 PM
environmental variables? blackzone Linux - General 1 08-06-2004 04:44 AM
how to set environmental variables chakkerz Linux - Newbie 8 07-01-2004 04:06 AM
environmental variables mbhenry Linux - General 6 09-18-2003 12:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 05:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration