View Full Version : Path set in Linux but not working as intended

04-03-2002, 11:43 PM
I added lines to /etc/profile in the same format that was in there.

I then tested it out by logging back in and running echo $PATH and it showed the directory in it.

I then ran the program I wanted and it reported that a file couldn't be found even though I located that file in the directory I put in the PATH.

I don't need to run ./program now I just need to go to the directory and run program. This does save me two keys but I really wanted to save me changing to that directory as this is the intention I wanted for PATH.

Is there something I am missing? The way they had PATHS set out in profile was confusing so I may have made a mistake in the setting up part of it.

05-03-2002, 03:21 PM
More information on what I had put in the profile.

if [ `id - u` = 0 ] && ! echo $PATH | /bin/grep -q '/progdir' ; then

That's the added lines I put in. I have no idea what it does but it did set the path up as progdir but still running it says that a file is missing which is also located in that progdir.

05-03-2002, 05:06 PM
The profile script is executed when anyone logs in.

That [ `id -u` = 0 ] tests whether you are logging on as root -- user 0. So you have set the path for root. Only for root. The rest of the clever stuff checks that the path to that programme has *not* been added already.

You would be better off to use the line:


instead. That will prepend (that is, 'append at the front') the 'path to progdir' to the rest of the PATH as it exists at that time. Regardless. It doesn't do any harm to have double entries --- I check my path every so often and delete any redundant entries.