Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 08-18-2003, 12:27 PM   #1
Registered: Aug 2003
Location: N.C.
Distribution: rh9, fc1, slack 9.1, 10
Posts: 229

Rep: Reputation: 30
Question appending PATH to automatically include subdirectories

when using the UNIX machines at school it seems as though the PATH environment variable automatically updates to include subdirectories from /home/user...when using rh9 on my laptop and the bash shell altering PATH in .bash_profile adds only the specific path and if i create a subdirectory from this directory executables are not recognized. is there a way to use wildcards such as PATH=$PATH:/home/user/newdirectory/* (i have tried this and know it not to work, but you get what i'm trying here...)

any help would be greatly appreciated. thanks
Old 08-20-2003, 08:41 AM   #2
Registered: Jul 2003
Location: Boston, MA, USA
Distribution: RedHat, SuSE, Gentoo, Slackware, Mandrake ...
Posts: 111

Rep: Reputation: 15
No, you can't put wildcards in your PATH. A common practice is to create a directory named $HOME/bin (where $HOME is your home directory) and put your own programs in there. The HOME environment variable is set up for you automatically by bash when you log in. It's also a common practice to let programs in your current directory be run, by putting "." in your PATH.

In your .bash_profile, therefore, you would put a line such as:
to add your private "bin" directory and your current directory to the end of your PATH. Note that the order of directories in PATH is important, so if you want your own programs to be used in the unlikely case that they have the same name as a system program, put your directories first.

Finally, if you have programs scattered around many sub-directories, and you don't want to move them to your "bin" directory (perhaps you update and recompile them frequently), then the thing to do is create a symbolic link from your "bin" directory to the program using "ln -s". For example, if you have a program at the pathname ~/projects/src/driller/drill, the command:
ln -s ~/projects/src/driller/drill ~/bin
will create a link to that program in your "bin" directory, and it will thus be found when the shell searches your PATH.
Old 08-20-2003, 04:59 PM   #3
Registered: Aug 2003
Location: N.C.
Distribution: rh9, fc1, slack 9.1, 10
Posts: 229

Original Poster
Rep: Reputation: 30

thanks mack,

adding the "." is exactly what i was looking for, as i am almost always in the executable's directory when i want to execute my programs for debugging etc. making a bunch of symbolic links just doesn't seem to be a good idea if you are continually recompiling so that the link wouldn't match your current build.

again thanks.


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
How to add subdirectories in PATH marconi Linux - General 3 08-27-2004 03:27 PM
where did my include path go aot2002 Linux - Wireless Networking 2 01-24-2004 05:02 AM
Path to include? Mazen Alzogbi Red Hat 1 11-15-2003 06:25 AM
PHP Path include ..:eMa:.. Programming 4 09-25-2003 01:59 AM
How to know the property a directory include the files and subdirectories? Xiangbuilder Linux - Newbie 3 08-31-2003 05:48 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:47 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration