LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   adding to $PATH (https://www.linuxquestions.org/questions/slackware-14/adding-to-%24path-85116/)

snocked 08-24-2003 06:49 AM

adding to $PATH
 
I just want to add cwd to path for all users. in my /etc/profile, I've pasted the portions involving the paths; however, adding the current dir or anything to default path and non-root users path still doesn't show up in path for all users. Yes I didn't forget to execute /etc/profile after editing it. :scratch:

# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games"

# For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in
# the $PATH. Some means of connection don't add these by default (sshd comes
# to mind).
if [ "`id -u`" = "0" ]; then
echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
if [ ! $? = 0 ]; then
PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
fi
fi

# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
PATH="$PATH:."
fi

leonscape 08-24-2003 06:56 AM

You adding a path cwd to PATH, or you want to add the Change Working Directory command?

snocked 08-24-2003 08:03 AM

current directory

leonscape 08-24-2003 08:27 AM

Re: adding to $PATH
 
Thats not something you should add to path. The current directory should be considered by anything using path anyway.

OR

Just because you can add ./ (Dot Slash). as in

PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:./"

But that shouldn't be necessary.

Tarts 08-24-2003 06:30 PM

Code:

if [ "`id -u`" = "0" ]; then
  echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
    export PATH=$PATH:.
  fi
fi

Knock yourself out...i think it's a bad idea though, or else it would be default.
{edit} 'man bash' there's a default location for these kind's of thing's.

snocked 08-25-2003 06:01 AM

That didn't work either. Plus that section is for root, and I want to add the path for all users on my system.

My point is that I should be able to do something as simple as adding to the path without any problems in slack, regardless of what I'm adding.


Tarts 08-25-2003 06:16 AM

Don't get down on slackware...there's power to be had in text file's.
If you want to add the current working directory for all user's...
do 'true' ('man true')
it's already that way. :)
take note that 'man bash', there's a default location for these file's, i believe it's bash.rc or .bashrc.

slakmagik 08-25-2003 06:18 AM

It *is* the default, or it's supposed to be - the end of /etc/profile should read similarly to Tarts' quote - and Tarts' and this are not for root:
Code:

# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
 PATH="$PATH:."
fi

Adding it to root's path is not the best idea but if you want it for user, what the hell. Or maybe it wasn't the default and I uncommented it. I forget. Whatever. :) I think you'll need to re-source profile for it to work, though - I forget how to do that other than just logging out and logging in again.

Tarts 08-25-2003 06:24 AM

Quote:

Originally posted by digiot
It *is* the default, or it's supposed to be - the end of /etc/profile should read similarly to Tarts' quote - and Tarts' and this are not for root:
Code:

# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
 PATH="$PATH:."
fi

Adding it to root's path is not the best idea
but if you want it for user, what the hell. Or maybe it wasn't the default and I uncommented it. I forget. Whatever. :) I think you'll need to re-source profile for it to work, though - I forget how to do that other than just logging out and logging in again.
Oh my mistake, i thought you wanted to add '.' to root's path. I hate to argue with you digiot, but i add my executable's dir. to root's path, i think that is ok. :) :) :)
{edit}
when i say my executable's dir. i mean my own executable's, the one's i make myself.

snocked 08-25-2003 06:28 AM

You can resource the /etc/profile by
. /etc/profile

linuxJaver 08-25-2003 06:29 AM

Add "." in the PATH is considered to be high risk of TrojanHorse.

Supposed some user on ur network or even an intruder is able to access certain location on ur sourceTree, maybe /var/ftp/incoming and put a shell script as "ls" with content "rm -rf /". That mean u ll need an new install after calling "ls" in that directory ..

That is why it is always recomended not to include "." in the PATH enviroment at all, that is why ppl must do "./configure" even if they are in the dir containing the configure script .. of any packaged they may have tried to install ..

slakmagik 08-25-2003 06:30 AM

Hm. I'm misreading all over the place. Well, the /etc/profile thing should work for users, anyway. Oof.

But go ahead and argue with me. :) I argue with conventional wisdom all I can but *nix permissions still utterly mystify me so I was just repeating what I understood as conventional wisdom there. :)

slakmagik 08-25-2003 06:33 AM

Quote:

Originally posted by linuxJaver
Add "." in the PATH is considered to be high risk of TrojanHorse.

Supposed some user on ur network or even an intruder is able to access certain location on ur sourceTree, maybe /var/ftp/incoming and put a shell script as "ls" with content "rm -rf /". That mean u ll need an new install after calling "ls" in that directory ..

That is why it is always recomended not to include "." in the PATH enviroment at all, that is why ppl must do "./configure" even if they are in the dir containing the configure script .. of any packaged they may have tried to install ..

But isn't the path searched *in order* of path listing? If '.' is on the *end* of your path it'll never *get* to the current directory before tripping over 'ls' in /bin first. So it wouldn't do anybody any good to stick a fake ls in a weird place. It isn't like DOS where the current directory is first.

snocked 08-25-2003 06:37 AM

This is just for practical purposes, and I just wanted to add it to all users system wide.

Yes, digiot, it's searched in order of listing.

slakmagik 08-25-2003 06:46 AM

And not-reading all over the place. I missed your profile tip the first time around. Thanks.

Yeah - so I still don't get the paths and permissions things. *sigh* I think that's the thing that gives me the most headaches.


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