LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-19-2009, 06:11 AM   #1
alanhr
LQ Newbie
 
Registered: Aug 2008
Distribution: Crunchbang Waldorf, Arch
Posts: 23

Rep: Reputation: 15
Unexpected directory in path, cannot find source


Hello all,

I have a problem with a directory in my PATH that should not be there. I have checked /etc/bashrc, /etc/profile, ~/.bashrc, ~/.bash_profile, and the two files that get sourced in by ~/.bashrc and cannot find the unwanted directory anywhere. Based on the order the directories are listed in my PATH, I think it is being inserted after /etc/bashrc and /etc/profile are called, but before ~/.bashrc and ~/.bash_profile are called. However, I cannot figure out how. Any ideas?

I realize I am probably missing something obvious, but at the moment I'm just spinning my wheels -- time to ask for help!

Oh, and in case it makes a difference: 64-bit RHEL 4.7 with bash shell (obviously).

Thanks,

Alan
 
Old 03-19-2009, 07:02 AM   #2
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
I don't know what is happening since I don't have access to your profile files, but anyway if you want a quick and dirty solution, just add that command in your ~/.bashrc:
export PATH=$(echo $PATH|sed 's/:badpath://g')
 
Old 03-20-2009, 01:59 AM   #3
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 668

Rep: Reputation: 134Reputation: 134
Quote:
Originally Posted by alanhr View Post
Hello all,

I have a problem with a directory in my PATH that should not be there. I have checked /etc/bashrc, /etc/profile, ~/.bashrc, ~/.bash_profile, and the two files that get sourced in by ~/.bashrc and cannot find the unwanted directory anywhere. Based on the order the directories are listed in my PATH, I think it is being inserted after /etc/bashrc and /etc/profile are called, but before ~/.bashrc and ~/.bash_profile are called. However, I cannot figure out how. Any ideas?

I realize I am probably missing something obvious, but at the moment I'm just spinning my wheels -- time to ask for help!

Oh, and in case it makes a difference: 64-bit RHEL 4.7 with bash shell (obviously).

Thanks,

Alan
/etc/profile sourced files from /etc/profile.d/ directory.
Culprit can be here
 
Old 03-20-2009, 06:39 AM   #4
alanhr
LQ Newbie
 
Registered: Aug 2008
Distribution: Crunchbang Waldorf, Arch
Posts: 23

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Valery Reznic View Post
/etc/profile sourced files from /etc/profile.d/ directory.
Culprit can be here
Thanks, I checked there but no luck.

I stopped sourcing the external files in my ~/.bashrc and now my PATH looks as it should. I still don't know where a couple of the entries (the ones that were duplicated before) are coming from.

Quote:
Originally Posted by Agrouf View Post
I don't know what is happening since I don't have access to your profile files,
Everything is very nearly just the RHEL defaults:

Code:
# /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


# 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

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

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

unset i
unset pathmunge
Code:
# .bash_profile

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

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME
Code:
# /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 [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; 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/~}\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/~}\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
        for i in /etc/profile.d/*.sh; do
	    if [ -r "$i" ]; then
	        . $i
	    fi
	done
	unset i
fi
# vim:ts=4:sw=4
Code:
# .bashrc

# User specific aliases and functions

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

# Set up Pango for 64-bit environment by default.
#
export PANGO_RC_FILE=/etc/pango/pangorc64
As I said, I quit sourcing any external files. All they did, though, was append stuff onto the PATH.

Thanks for the advice,

Alan
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find a file path and directory path ak.lokesh Linux - Newbie 3 02-19-2009 01:37 PM
mounting a vfat partition: (one) directory has unexpected permissions deftone` Linux - General 6 08-12-2008 11:26 AM
Cannot find kernel source directory in Sarge knuhe Debian 12 05-25-2006 06:41 PM
how to find a relative path to another directory bahadur Programming 9 04-04-2005 08:52 PM
How to find Linux source directory? adelaideyip Linux - Newbie 7 08-20-2004 05:58 PM


All times are GMT -5. The time now is 02:30 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration