PATH question (newbie)

Matthew S-H mathbymath at aol.com
Mon Apr 18 03:34:35 UTC 2005


I followed your advice on this one and it seems to work pretty much  
fine.  I changed the line a bit though:
"PATH=$PATH:$(echo /opt/*/bin|sed -e 's/ /:/g'); PATH=$PATH: $(echo  
/opt/*/*.bin|sed -e 's/ /:/g')"

I did this because I had Java installed at "/opt/jre1.5.0_02".  The  
binaries are in "/opt/jre1.5.0_02/bin/", and they are called "java",  
"java_vm", and "javaws".

Here are my questions/problems:
When I use this, it also includes all of the other binaries in that  
folder.  I don't want there to be binaries such as "ControlPanel",  
"klist", "kinit", "orbd", etc. in my PATH.  What can I o to include  
only some of the binaries in that folder?

Also, just as an idea, what about creating a subdirectory of /opt/  
called something like "symbolic_links" and creating symbolic links to  
all the executables in the other folders of /opt/?  I wouldn't mind  
creating a new symbolic link each time I installed a new piece of  
software.  The only problem I can think of with this idea is that I am  
not quite sure how to create a symbolic link.  I know it involves "ln",  
but I am not quite sure which parameters I should use.


Anyway, thanks for your help.

~Matt

On Apr 17, 2005, at 9:47 PM, Rob Park wrote:

> On 4/17/05, Matthew S-H <mathbymath at aol.com> wrote:
>> How do I change my PATH to include everything in /opt/ ?
>
> Ok, the other guys are freaking out telling you this is a bad idea,
> but I think I understand your question more than they do.
>
> Back in the days when I used to run LFS[0], I'd install programs into
> /opt/programname instead of the default /usr/local that most packages
> like to install to. Effectively, /opt became something like the
> equivalent of Windows' C:\Program Files directory. Each program has
> it's own subdirectory there. I assume that this is what you are doing.
> And now you want the programs you've installed to be in your path.
>
> This is not a problem. What you want to do is something like this:
>
> PATH=$PATH:$(echo /opt/*/bin|sed -e 's/ /:/g')
>
> So lets say you've got 3 programs installed into /opt: "foo", "bar",
> and "test". Each of these programs keeps it's binaries in "bin"
> directory below their own directory. This means you need to add
> /opt/foo/bin, /opt/bar/bin, and /opt/test/bin to your path in order to
> run those programs. The above snippet is very simple, The first thing
> it does is expands /opt/*/bin (which is to say, it finds all the
> directories in /opt that contain a subdirectory called "bin", and then
> prints that out:
>
> $ echo /opt/*/bin
> /opt/bar/bin /opt/foo/bin /opt/test/bin
>
> Then we need to change the spaces into colons (":"), because that's
> how the $PATH variable separates each directory in the path:
>
> $ echo /opt/*/bin|sed -e 's/ /:/g'
> /opt/bar/bin:/opt/foo/bin:/opt/test/bin
>
> Then we need to add this on to the end of the current $PATH variable:
>
> $ echo $PATH:$(echo /opt/*/bin|sed -e 's/ /:/g')
> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/ 
> X11:/opt/bar/bin:/opt/foo/bin:/opt/test/bin
>
> And then finally we assign the resulting value back into the $PATH  
> variable:
>
> PATH=$PATH:$(echo /opt/*/bin|sed -e 's/ /:/g')
>
> You'll want to save that in your ~/.bashrc so that it gets set each
> time you log in, so you don't have to keep writing it.
>
> -- 
> Urban Artography
> http://artography.ath.cx
>
> -- 
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> http://lists.ubuntu.com/mailman/listinfo/ubuntu-users





More information about the ubuntu-users mailing list