LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-14-2003, 03:33 AM   #1
chri5
LQ Newbie
 
Registered: Nov 2003
Posts: 22

Rep: Reputation: 15
Adding to the $PATH


Hello,
I would like to add to the system wide $PATH in red hat 9.
Which file should I edit to achive this?

Examples would be appreciated!

Thanks,
Chris.
 
Old 11-14-2003, 03:42 AM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
In Slack it's /etc/profile - that much *should* be the same in RH.
 
Old 11-14-2003, 03:51 AM   #3
chri5
LQ Newbie
 
Registered: Nov 2003
Posts: 22

Original Poster
Rep: Reputation: 15
ok my /etc/profile

looks like this:-
-------------------------------------
# /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

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
---------------------------------------

Where and how would I place additions to the system wide $PATH into the above /etc/profile ?

Thanks,
Chris
 
Old 11-14-2003, 03:52 AM   #4
Y0jiMb0
Member
 
Registered: Jul 2003
Location: Valencia (Spain)
Distribution: slackware 11, FEDORA CORE 4, RHEL3, Gentoo...
Posts: 361

Rep: Reputation: 30
Quote:
In Slack it's /etc/profile - that much *should* be the same in RH.
in mandrake too
example:
Code:
export PATH=$PATH:/usr/games
adds /usr/games to the path environment variable.
adding to /etc/profile the next
Code:
if ! echo ${PATH} |grep -q /usr/games ; then
    PATH="$PATH:/usr/games"
fi
could be useful if you want this directory always in your path.
Take a look at /etc/profile, you maybe have more clues there...
Regards
 
Old 11-14-2003, 04:10 AM   #5
chri5
LQ Newbie
 
Registered: Nov 2003
Posts: 22

Original Poster
Rep: Reputation: 15
There are many directories in my $PATH:-

bash: /usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/bo1cps/bin: No such file or directory

Some of these do not appear in the /etc/profile

Where are these directories coming from?

Would it be ok to add:-

if ! echo ${PATH} |grep -q /usr/games ; then
PATH="$PATH:/usr/games"
fi

anywhere in the /etc/profile ?

Thanks,
Chris.
 
Old 11-14-2003, 04:25 AM   #6
Y0jiMb0
Member
 
Registered: Jul 2003
Location: Valencia (Spain)
Distribution: slackware 11, FEDORA CORE 4, RHEL3, Gentoo...
Posts: 361

Rep: Reputation: 30
Quote:
Would it be ok to add:-

if ! echo ${PATH} |grep -q /usr/games ; then
PATH="$PATH:/usr/games"
fi

anywhere in the /etc/profile ?
I thin so; here you have my /etc/prfiles, just in case...
Code:
# /etc/profile -*- Mode: shell-script -*-
# (c) MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com>

loginsh=1

# Users generally won't see annoyng core files
[ "$UID" = "0" ] && ulimit -S -c 1000000 > /dev/null 2>&1

if ! echo ${PATH} |grep -q /usr/X11R6/bin ; then
    PATH="$PATH:/usr/X11R6/bin"
fi

if [ "$UID" -ge 500 ] && ! echo ${PATH} |grep -q /usr/games ; then
    export PATH=$PATH:/usr/games
fi

umask 022

USER=`id -un`
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
HISTCONTROL=ignoredups
HOSTNAME=`/bin/hostname`
HISTSIZE=1000

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

# some old programs still use it (eg: "man"), and it is also
# required for level1 compliance for LI18NUX2000
NLSPATH=/usr/share/locale/%l/%N

export PATH PS1 USER LOGNAME MAIL HOSTNAME INPUTRC NLSPATH
export HISTCONTROL HISTSIZE

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

unset i
Regards
 
Old 11-14-2003, 04:31 AM   #7
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Quote:
Originally posted by chri5
Where are these directories coming from?
I hesitate to say with RH but some path definition comes from /etc/profile, some from your various bash initialization scripts. Maybe other places.

Yeesh. RH scripts are ugly.
 
Old 11-14-2003, 04:44 AM   #8
chri5
LQ Newbie
 
Registered: Nov 2003
Posts: 22

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by digiot
Yeesh. RH scripts are ugly.
I'll second that! Thanks for eveyones help...
 
Old 11-14-2003, 10:38 AM   #9
Skyline
Senior Member
 
Registered: Jun 2003
Distribution: Debian/other
Posts: 2,104

Rep: Reputation: 45
........... or more simply (for example)

PATH=$PATH:/home/john/programs

export PATH

If you now check your PATH with

echo $PATH

you'll see the new directory at the end of the colon separated list of directories in your PATH variable.
 
  


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
adding to $PATH poiuytrewq Linux - Newbie 3 10-27-2004 01:32 AM
Adding a PATH in SuSE 8.2 Nokia Linux - Software 1 08-25-2004 03:54 PM
adding to path hamish Linux - Software 8 02-05-2004 10:03 PM
Adding an entry to the PATH Pimple Solaris / OpenSolaris 6 09-25-2003 12:40 PM
adding to $PATH snocked Slackware 17 08-26-2003 12:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:50 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