Having /sbin in PATH (non root user)


Rockthesmurf

Advanced Member
Joined
Jul 18, 2003
Messages
1,115
Age
40
Location
Manchester, UK
Website
Visit site
Could anyone advise whether it would be a bad idea for me to add /sbin to be in the path of a non root user?

When I first set up Slackware on my Pandora I thought it didn't come with some basic command line executables (like ifconfig) as some instructions I followed indicated ifconfig should be in the path for a non-root user. It wasn't until I made further Google queries regarding ifconfig on Slackware that I found out I can call it directly from it's absolute path (e.g. /sbin/ifconfig).

This page makes the suggestion /sbin could be added to the path: http://linuxcommando.blogspot.co.uk/2008/05/run-ifconfig-as-non-root-user-for-read.html and makes a note that if you do this, and then perform operations with ifconfig that really do require elevated privileges, they will of course fail with a "Permission denied' message (which seems reasonable).

EDIT: Question would be better placed in the other OS section of the forum, I can't see how I can change this now, if a moderator wants to move it and then remove this edit that would be cool.
 
Last edited by a moderator:
The simplest way is:

Create or edit .bashrc (at the root of your home folder), fill it with:

export PATH=$PATH:/sbin
 
Last edited by a moderator:
@Linux-SWAT: Thanks for this, however, my question is actually more to do with whether there is any advise against doing this? Or, put another way, it feels like having /sbin in the path by default would be a good thing, how comes it is not in Slackware? Is it because it is deemed the programs in /sbin aren't really of interest to 'normal' users, so by not putting them in the path it hides said users from these programs?
 
I've seen it vary by distribution.. If the rest permissions are doing their job properly, I say it's fairly safe.
 
ITs tradition not to bundle a system with sbin in there, but yeah.. over the years I just /sbin/foo it, but once in awhile have gotten lazy and just appended it to the path.

There should be no risk; toolsbeing malicious are doing somethign far nastier (they know about paths too), and fat fingering .. always a risk, so be careful :)

jeff

edit: you know, at my company, it seems every other person likes to use 'vi' when they really mean 'more'. _thats_ the real danger :eek: (lets not start a real list; failure to use a revision control system, loving to use an editor to view a file, not managing permissions right, naming a job 'test' where there is a real command line tool 'test' and then add "." into $PATH vausing weird havoc...

if you want to take over a company, create a sh-script called 'ls' and stick it in various public writable dirs, and see how many idiots will use it (ie: ./ls or having . in their PATH)..
 
Last edited by a moderator:
ITs tradition not to bundle a system with sbin in there, but yeah..
Well, kinda all Debian based/inspired systems break this 'tradition' (at least for the root user)... So it actually has been very common for ages, just not in the Red Hat and Slackware realms. Strike that, didn't get the "non-root user". Ubuntu seems to do it a lot, though.
 
Last edited by a moderator:
All the nice government crackers using your pandora to check that you aren't a terrorist will keep all the nasty script kiddies from deleting /home
 
Last edited by a moderator:
Back
Top