The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
$PWD shows absolute path vs path w/symbolic links kornshellmaven Shell Programming and Scripting 3 06-13-2007 12:15 PM
getting full path from relative path polypus Shell Programming and Scripting 4 03-25-2007 12:08 PM
how to check the actual path instead of link path reldb UNIX for Advanced & Expert Users 4 10-04-2006 09:55 AM
vi - replacing a relative path with absolute path in a file Yinzer955i UNIX for Dummies Questions & Answers 2 09-07-2006 11:47 AM
cc path problem - no acceptable path found kendokendokendo UNIX for Dummies Questions & Answers 2 09-12-2005 09:52 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-18-2008
msb65 msb65 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 89
Modify Path

Hi,

This is certainly a simple question, but I have yet to receive sufficient info concerning it. I am using BASH on a Powerbook G4 running Leopard.

- I would like to permanently add a directory to my path. How do I do this?

- I understand that I can view my path by: echo $PATH. Is there a file where the path is displayed as well.

Thank you very much for any help.

Mike
  #2 (permalink)  
Old 11-18-2008
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
look for file named .bash_profile in your home directory. in this file, add a line similar to:
Code:
export PATH=$PATH:/my/dir/path
  #3 (permalink)  
Old 11-18-2008
msb65 msb65 is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 89
Hi Yogesh,

I appreciate your help. Perhaps you can clear up one other path related issue.

- Why modify the .bash_profile instead of the .bashrc?

- Like I said I am using BASH on a Mac running Leopard. For the most part I use Terminal for my command line related work. However, sometimes I use X11 as well. I noticed that when i typed "echo $PATH" in a Terminal shell it returned a different series of directories than when I did the same in an X11 shell. I believe this is because those two programs check different environment files. Is that correct?

A user in a different forum suggested that I modify my .bash_profile and .bashrc files. Can you tell what exactly is going on? Here are the contents:

#####
.bash_profile:
if [ -f ~/.aliases ]; then
. ~/.aliases
fi

ulimit -Ss unlimited
source /Users/msb65/seadas5.2/config/seadas.env
#####

#####
.bashrc:

if [ -f ~/.bash_profile ]; then
. ~/.bash_profile
fi
#####
  #4 (permalink)  
Old 11-18-2008
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,909
Quote:
Originally Posted by msb65 View Post
Hi Yogesh,

I appreciate your help. Perhaps you can clear up one other path related issue.

- Why modify the .bash_profile instead of the .bashrc?
On your system there seems to be no difference between the two; one always sources the other if it exists. On my system, .bashrc is always sourced when I login, but .bash_profile is skipped for noninteractive shells.
Quote:
Like I said I am using BASH on a Mac running Leopard. For the most part I use Terminal for my command line related work. However, sometimes I use X11 as well. I noticed that when i typed "echo $PATH" in a Terminal shell it returned a different series of directories than when I did the same in an X11 shell. I believe this is because those two programs check different environment files. Is that correct?
Maybe. I've noticed that Apple sometimes customizes these things in odd ways.
Quote:
A user in a different forum suggested that I modify my .bash_profile and .bashrc files. Can you tell what exactly is going on? Here are the contents:
Please use code tags for code. like [ code ] asdf [ /code ] except without the extra spaces.

Code:
# Checks if the ~/.aliases file exists;  if it does, sources it.
if [ -f ~/.aliases ]; then
. ~/.aliases
fi

# Something to do with file size limits.  Mine doesn't have -Ss, so see
# 'man ulimit' on your system..
ulimit -Ss unlimited

# Includes some mac-specific environment variables, perhaps
source /Users/msb65/seadas5.2/config/seadas.env
Code:
# If .bash_profile exists, source it.
if [ -f ~/.bash_profile ]; then
. ~/.bash_profile
fi
  #5 (permalink)  
Old 11-18-2008
pupp's Avatar
pupp pupp is offline Forum Staff  
cap_10hdx 1
  
 

Join Date: Feb 2008
Location: Jersey Shore
Posts: 542
upon the start of a login shell, the bash will consult the below files in this order:
1. /etc/profile
2. ~.bash_profile
3. ~.bash_login
4. ~.profile
when you start a nonlogin shell, bash consults only ~bashrc.

so there is a difference between them. however, thats not to say osx is different. i'm not sure about this. this is more typical of linux/solaris.
Sponsored Links
Closed Thread

Bookmarks

Tags
bashrc

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 02:52 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0