sudo command PATH problem

Hey,

My sudo command doesn’t see all of my path. Is this a normal behaviour. If not how do I fix this?

For example:

sudo service ***** start

gives me a command not found


su
service ***** start

This works.

And this is not the only example of this.

sudo /sbin/service **** start

That is more typing. Is this really necessary? Security concern maybe?

Since I think sbin is for System Binaries, my first guess is YES, it’s a Security Concern.

On Fri, 18 Mar 2011 03:06:02 +0000, yasar11732 wrote:

> My sudo command doesn’t see all of my path. Is this a normal behaviour.
> If not how do I fix this?

IIRC, sudo uses the path defined by the current user rather than the root
user (or the user you’re switching to.

Try:

sudo echo $PATH

and see what comes back.

Then compare that to:

su
echo $PATH

and

su -
echo $PATH

(The latter is what is generally recommended)

Jim

Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

sudo -i …

What does this do?

man sudo

From
man sudo

   -i [command]
               The -i (simulate initial login) option runs the shell specified in the passwd(5) entry of
               the target user as a login shell.  This means that login-specific resource files such as
               .profile or .login will be read by the shell.  If a command is specified, it is passed to
               the shell for execution.  Otherwise, an interactive shell is executed.  sudo attempts to
               change to that user's home directory before running the shell.  It also initializes the
               environment, leaving DISPLAY and TERM unchanged, setting HOME, SHELL, USER, LOGNAME, and
               PATH, as well as the contents of /etc/environment on Linux and AIX systems.  All other
               environment variables are removed.

On 03/18/2011 04:06 AM, yasar11732 wrote:
>
> My sudo command doesn’t see all of my path. Is this a normal behaviour.
> If not how do I fix this?

security is the reason [sudo here is different from sudo in (say)
Ubuntu or others]…try

su -c ‘service ***** start’

which is 3 strokes longer…

some ‘repair’ the sudo path, i’d rather have the extra strokes…

hmmmmmm, i’ve not thought about how to alias it…
just now i has s =‘su -’
i guess maybe sc could be ‘su -c’ and then

sc ‘service ***** start’

would be the same strokes as your sudo string…

lots of cats to skin.


DenverD
CAVEAT: http://is.gd/bpoMD
[NNTP posted w/openSUSE 11.3, KDE4.5.5, Thunderbird3.1.8, nVidia
173.14.28 3D, Athlon 64 3000+]
“It is far easier to read, understand and follow the instructions than
to undo the problems caused by not.” DD 23 Jan 11

Another solution would be to simply add this line to your ~/.bashrc file :

export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin

Best regards,
Greg