Re: export PATH (newbie question)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Rodolpho-


On Saturday, October 18, 2003, at 10:29 PM, Rodolfo J. Paiz wrote:


Hello all-

I have googled, searched the archive, and read my RH Linux books, and I must be missing something here.

What you want here is "man bash", just so you know.

I'm not going to touch the feminist jokes that could be made about "man bash"-ing ;) Seriously though, I did glance at it earlier (and more in-depth now), and it is suffering from a serious case of TMI (too doggone much information...) Trying to find the pertinent paragraph in the manual is almost impossible... <sigh...>

I have a program that I want to run from the command line on a fairly frequent basis, and do not want to have to specify the path every time (as it is several directories down), so after having done the above research, I see that I can type:

export PATH=$PATH:/directory/subdirectory

which adds the necessary directory to my path variable. Works fine, and I can run my little program to my heart's content, just by typing it's name. Fine...

That is, until I reboot, at which point my PATH variable goes back to whatever it was set up to by Red Hat, and I have to type the above command in again (or just navigate to the program I am trying to start). What a pain! I am guessing that there is a file somewhere (in /etc?) that stores a PERSISTANT copy of the PATH variable, and that this is where I need to make my changes. Can anyone point me in the right direction? If it makes a difference, I am using Fedora Core test 3, with all Rawhide updates.

There are two places in which to change your path:


1. In /etc, as you guessed, there is a bashrc file. This file gets read for _all_ bash logins so whatever is in it will take effect for all users who use bash the next time they log in. Note the name of the file is "/etc/bashrc" with no dots in it. You can modify your path here and it will work for all users.

Looking in /etc/bashrc, it seems to point to /etc/profile for "Environmental Stuff". Looking through the bashrc file, it seems to be involved with setting up the bash environment (I do not see any reference to the default paths). When I look in /etc/profile, there IS a mention of "Path Manipulation", with the following;


if [ 'id -u' = 0 ]; then
	pathmunge /sbin
	pathmunge /usr/sbin
	pathmunge /usr/local/sbin
fi

pathmunge /usr/X11R6/bin after

unset pathmunge

This, however, does not match up (at all) with my actual default path, of:

/usr/Kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/x11R6/bin:/home/ smearp/bin

2. In your home directory, there is a ".bashrc" file (note it starts with a dot). This file gets read when you log in, after the /etc/bashrc file so that user-specific configurations can override general ones. You can also modify your path here, but it will only take effect for you.

However, changing the path is not the only way to solve this. Another is to use the alias command and put into your .bashrc or into /etc/bashrc the following line:

alias prog='/usr/local/bin/path/to/some/place/prog'

Now, when you type "prog 33" the bash shell will immediately replace prog with that long path and the program should run correctly. That way you don't modify the path at all. :-)

Does that make sense?

Well... yes and no. First of all, you solved my initial problem. I can add whatever path I want to either /etc/bashrc (global) OR /home/smearp/.bashrc (local) OR /etc/profile (global again), by typing either: export PATH=$PATH:/some/path or alias prog='/path/to/program'


I suppose that if there aren't at least six ways to do something, it isn't worth doing ;)

Now, out of plain old curiosity, where DOES bash get the default path from (as set by the administrator or RH), as it does not show up in ANY of the 3 files above???

Thanks for your help,

-Sean


-- redhat-list mailing list unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux