LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 08-24-2003, 06:49 AM   #1
snocked
Member
 
Registered: Dec 2002
Location: St. Louis, MO
Distribution: Slackware 9.1
Posts: 482

Rep: Reputation: 30
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.

# 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

Last edited by snocked; 08-24-2003 at 08:23 AM.
 
Old 08-24-2003, 06:56 AM   #2
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 47
You adding a path cwd to PATH, or you want to add the Change Working Directory command?
 
Old 08-24-2003, 08:03 AM   #3
snocked
Member
 
Registered: Dec 2002
Location: St. Louis, MO
Distribution: Slackware 9.1
Posts: 482

Original Poster
Rep: Reputation: 30
current directory
 
Old 08-24-2003, 08:27 AM   #4
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 47
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.

Last edited by leonscape; 08-24-2003 at 08:28 AM.
 
Old 08-24-2003, 06:30 PM   #5
Tarts
Member
 
Registered: Feb 2003
Distribution: Slackware 9.1 (exclusively) ;)
Posts: 344

Rep: Reputation: 30
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.

Last edited by Tarts; 08-24-2003 at 10:58 PM.
 
Old 08-25-2003, 06:01 AM   #6
snocked
Member
 
Registered: Dec 2002
Location: St. Louis, MO
Distribution: Slackware 9.1
Posts: 482

Original Poster
Rep: Reputation: 30
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.


Last edited by snocked; 08-25-2003 at 06:04 AM.
 
Old 08-25-2003, 06:16 AM   #7
Tarts
Member
 
Registered: Feb 2003
Distribution: Slackware 9.1 (exclusively) ;)
Posts: 344

Rep: Reputation: 30
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.

Last edited by Tarts; 08-25-2003 at 06:19 AM.
 
Old 08-25-2003, 06:18 AM   #8
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
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.
 
Old 08-25-2003, 06:24 AM   #9
Tarts
Member
 
Registered: Feb 2003
Distribution: Slackware 9.1 (exclusively) ;)
Posts: 344

Rep: Reputation: 30
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.

Last edited by Tarts; 08-25-2003 at 06:30 AM.
 
Old 08-25-2003, 06:28 AM   #10
snocked
Member
 
Registered: Dec 2002
Location: St. Louis, MO
Distribution: Slackware 9.1
Posts: 482

Original Poster
Rep: Reputation: 30
You can resource the /etc/profile by
. /etc/profile

Last edited by snocked; 08-25-2003 at 06:33 AM.
 
Old 08-25-2003, 06:29 AM   #11
linuxJaver
Member
 
Registered: Jul 2003
Location: Jakartax, ID
Distribution: slack9.1+,9.1,rh9
Posts: 203

Rep: Reputation: 30
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 ..
 
Old 08-25-2003, 06:30 AM   #12
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
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.
 
Old 08-25-2003, 06:33 AM   #13
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
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.
 
Old 08-25-2003, 06:37 AM   #14
snocked
Member
 
Registered: Dec 2002
Location: St. Louis, MO
Distribution: Slackware 9.1
Posts: 482

Original Poster
Rep: Reputation: 30
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.
 
Old 08-25-2003, 06:46 AM   #15
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
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.
 
  


Reply


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
adding to $PATH poiuytrewq Linux - Newbie 3 10-27-2004 01:32 AM
Adding a PATH in SuSE 8.2 Nokia Linux - Software 1 08-25-2004 03:54 PM
adding to path hamish Linux - Software 8 02-05-2004 10:03 PM
Adding to the $PATH chri5 Linux - Newbie 8 11-14-2003 10:38 AM
Adding an entry to the PATH Pimple Solaris / OpenSolaris 6 09-25-2003 12:40 PM


All times are GMT -5. The time now is 05:09 AM.

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