LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   As root, not seeing /sbin and /usr/sbin in path (http://www.linuxquestions.org/questions/linux-newbie-8/as-root-not-seeing-sbin-and-usr-sbin-in-path-174427/)

weghman 04-25-2004 12:57 PM

As root, not seeing /sbin and /usr/sbin in path
 
Hello Everyone,

I am running Fedora Core 2. I do not have /sbin and /usr/sbin in my path when I switch to root and type echo $PATH.

Below is my /etc/profile file. It seems to me that although I have added additional paths to my PATH variable, the sbin paths should still show up in $PATH. What am I doing wrong?

Thanks - Dan


# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}

# Path manipulation
if [ `id -u` = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi

pathmunge /usr/X11R6/bin after

unset pathmunge

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"

HOSTNAME=`/bin/hostname`
HISTSIZE=1000

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then
INPUTRC=/etc/inputrc
fi

WAS_HOME='/opt/WebSphere/AppServer'
CATALINA_HOME='/opt/tomcat'
IBMIHS_HOME='/opt/IBMIHS'
ANT_HOME='/usr/local/apache-ant-1.6.1'
PATH=$PATH:./:/usr/local/Acrobat5/bin:/usr/local/apache-ant-1.6.1/bin

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC WAS_HOME CATALINA_HOME IBMIHS_HOME ANT_HOME


for i in /etc/profile.d/*.sh ; do
if [ -r "$i" ]; then
. $i
fi
done

unset i

bulliver 04-25-2004 01:03 PM

Hmmm, seems to me that .bash_profile only gets read when you initially log in at the console, not when you SU to root.

I would put:
"export PATH=$PATH:/sbin:/usr/sbin"
into root's .bashrc file (which gets read when you SU...)

david_ross 04-25-2004 01:03 PM

When you switch to root - do you use "su"? Try "su -".

weghman 04-25-2004 01:06 PM

Ah - yes! You are both right. I need to switch to root using su -

Thank you so much for your quick replies.


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