LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-02-2010, 11:43 AM   #1
crypted
Member
 
Registered: Jan 2004
Posts: 59

Rep: Reputation: 15
Root PATH isn't right, can't change


After upgrading to CentOS 5.4, my root path seems screwed.

The issue is present for CRONJOBs that run as the root user as well as when I su to the user through SSH.

I need the following path ALWAYS:
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin

It currently only gives root:
/usr/kerberos/sbin /usr/kerberos/bin /usr/local/bin /bin /usr/bin /usr/X11R6/bin

I have tried adding export PATH to the .bash_profile and set PATH = in the .tcshrc. Neither of those attempts work for my SSH session nor did it work for the root cronjob tasks.

Code:
# /root/ispconfig/php/php -q /root/ispconfig/scripts/writeconf.php
sh: httpd: command not found
ls: /conf.d/*.conf: No such file or directory
sh: httpd: command not found
start
sh: postmap: command not found
sh: httpd: command not found
Segmentation fault
The scripts were working just fine for two years. I haven't changed anything. Just stopped working after the upgrade. It's based upon the PATH issue though.

Any help is much appreciated!!!
 
Old 04-02-2010, 11:52 AM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
What's in your .bash* files? How about the system wide defaults in /etc? You should be able to add:

export PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin

In several locations and get the changes you need.
 
Old 04-02-2010, 12:00 PM   #3
crypted
Member
 
Registered: Jan 2004
Posts: 59

Original Poster
Rep: Reputation: 15
Code:
# cat .bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:/bin:/usr/sbin:/sbin

export PATH
unset USERNAME
Code:
# cat .bashrc 
# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
Code:
 cat bashrc 
# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# By default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then
        umask 002
else
        umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
    case $TERM in
        xterm*)
                if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
                else
                PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\007"'
                fi
                ;;
        screen)
                if [ -e /etc/sysconfig/bash-prompt-screen ]; then
                        PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
                else
                PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}"; echo -ne "\033\\"'
                fi
                ;;
        *)
                [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
            ;;
    esac
    # Turn on checkwinsize
    shopt -s checkwinsize
    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
fi

if ! shopt -q login_shell ; then # We're not a login shell
        # Need to redefine pathmunge, it get's undefined at the end of /etc/profile
    pathmunge () {
                if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
                        if [ "$2" = "after" ] ; then
                                PATH=$PATH:$1
                        else
                                PATH=$1:$PATH
                        fi
                fi
        }

        # Only display echos from profile.d scripts if we are no login shell
    # and interactive - otherwise just process them to set envvars
    for i in /etc/profile.d/*.sh; do
        if [ -r "$i" ]; then
            if [ "$PS1" ]; then
                . $i
            else
                . $i >/dev/null 2>&1
            fi
        fi
    done

        unset i
        unset pathmunge
fi
# vim:ts=4:sw=4
I modified the .bash_profile but didn't work out. As far as SSH, I use TCSH as my shell. Always have.

This just started happening after the upgrade from 5.3 -> 5.4.

I added that line you gave me to all of those files above. I still don't get the proper path.

Last edited by crypted; 04-02-2010 at 12:03 PM.
 
Old 04-03-2010, 08:17 AM   #4
nonamenobody
Member
 
Registered: Oct 2002
Posts: 138

Rep: Reputation: 22
Does cron use your typical environment files? I didn't think that it did, I thought that you normally had to specify the full path in crontab entries and cron files. But that doesn't explain why it was working before and not now.

You mention that you don't get the correct path when you SSH in and that you use tcsh when you SSH. You also mention that you have edited various bash rc-files, however that isn't likely to make much difference if you are using tcsh.
 
Old 04-03-2010, 11:37 AM   #5
crypted
Member
 
Registered: Jan 2004
Posts: 59

Original Poster
Rep: Reputation: 15
Understood. I couldn't get my .tcsh customizations to work. So, I went to bash and the path seems okay for SSH. Now, I still have an issue with segmentation faults.

And, as I outlined in a new thread, most of the time my PHP sites only load as the PHP source text in the browser.
 
  


Reply



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
change windows path to unix path gibsosmart Linux - Newbie 7 09-15-2009 03:35 AM
script to change unix path to windows path in all files csross Programming 8 04-29-2006 01:05 PM
keep change in PATH alchem Linux - Newbie 11 08-28-2005 04:08 PM
How do I retain the PATH in the root account even when I switch to root using su? thearchitect Linux - Newbie 1 08-13-2005 12:02 AM
Change root PATH setting ust Linux - Distributions 1 05-16-2005 07:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:45 AM.

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