LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
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 01-28-2002, 02:25 AM   #1
Sonny
Newbie
 
Registered: Jan 2002
Location: Burnaby British Columbia
Distribution: Redhat 7.1
Posts: 25

Rep: Reputation: 15
Setting up PATH


Hi Guys,

I am having problems figuring out how my PATH is being set. My understanding is that once per login, the script in .bash_profile is executed. And each time I start another shell, the script file .bashrc is executed.

The following is the contents of my .bash_profile.
# .bash_profile

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

# User specific environment and startup programs

PATH=$PATH:$HOME/tools/snavigator/bin:$HOME/tools/office52
BASH_ENV=$HOME/.bashrc
USERNAME=""

export USERNAME BASH_ENV PATH

Now when I type echo $PATH I get:


/usr/bin:/bin:/usr/X11R6/bin:/usr/local/bin:/opt/bin:/usr/X11R6/bin:/home/sonnyc/tools/snavigator/bin:/home/sonnyc/tools/office52:/usr/X11R6/bin:/home/sonnyc/tools/snavigator/bin:/home/sonnyc/tools/office52

Notice that the last 2 directories are repeated. Why is that?


Sonny.

 
Old 01-28-2002, 03:57 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
Well you haven't included the contents of the .bashrc file. But if you look at the first part of the .bash_profile file you'll see that it runs that file. So if you are also setting the path in that file then it will get set twice.
 
Old 01-28-2002, 07:04 AM   #3
Sonny
Newbie
 
Registered: Jan 2002
Location: Burnaby British Columbia
Distribution: Redhat 7.1
Posts: 25

Original Poster
Rep: Reputation: 15
Hi Mik,

I did check the .bashrc file to ensure that I was not adding to the PATH. As you can see from below, the .bashrc just sets some aliases and executes the /etc/bashrc file.

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias ls="ls --color"
alias ll="ls -lh --color=tty"
alias lo="ls -oh --color=tty"
alias llt="ls -l --full-time"

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

I have not modified the /etc/bashrc file nor any files that /etc/bashrc executes so I'm pretty sure the doubling up on the directories in the PATH are not coming from this source. In addition, when I comment out the PATH line in the .bash_profile, and then echo $PATH, I get:

/usr/bin:/bin:/usr/X11R6/bin:/usr/local/bin:/opt/bin:/usr/X11R6/bin:/usr/X11R6/bin

So it appears that .bash_profile is executed twice(?).

Sonny.
 
Old 01-28-2002, 12:41 PM   #4
tiamat
LQ Newbie
 
Registered: Jan 2002
Location: Sweden
Distribution: Redhat
Posts: 17

Rep: Reputation: 0
you got ~/.bashrc ~/.bash_profile /etc/bashrc.
 
Old 01-28-2002, 02:02 PM   #5
Sonny
Newbie
 
Registered: Jan 2002
Location: Burnaby British Columbia
Distribution: Redhat 7.1
Posts: 25

Original Poster
Rep: Reputation: 15
Hi Taimat,

Yes, that is correct I have ~/.bashrc, ~/.bash_profile and /etc/bashrc. As I mentioned in my previous post, /etc/bashrc and ~/.bashrc can not be contributing to my PATH since I have not modified them. The PATH has the repeating directories when I insert the script that modifies it in the ~/.bash_profile (see my previous posts) and does not have them at all when I remove it from ~/.bash_profile.

Sonny.
 
  


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
Setting the path powerlifter450 Linux - Software 18 07-05-2006 11:46 AM
Setting the path.... joel112 Slackware 5 08-28-2003 02:27 PM
Setting the path Milkman00 Linux - General 2 07-26-2002 09:44 AM
setting PATH tda Linux - Newbie 1 04-29-2002 01:54 PM
PATH SETTING webboss Linux - Newbie 2 03-17-2001 06:29 PM


All times are GMT -5. The time now is 10:22 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration