VMware Cloud Community
thickclouds
Enthusiast
Enthusiast
Jump to solution

SU and SUDO

I have always cheated and enabled root for SSH but am now trying to do it the right way and not allow root access through SSH.

I am missing something on the su and sudo commands. The "vdf" command does not work and esxcfg-??? command set is also not available. Can someone please help me understand how to use the administrative commands with sudo or su?

Thanks!

Charlie Gautreaux vExpert http://www.thickclouds.com
Reply
0 Kudos
1 Solution

Accepted Solutions
dwight
Enthusiast
Enthusiast
Jump to solution

Sudo runs a command as root but doesn't use the root user's environment settings. Specifically the root user's path normally searches the /sbin and /usr/sbin directories and a by default normal users do not. Since those directories contain the commands you mentioned they won't work in sudo without specifying the full path to the command.

The following commands will add the appropriate directories to the search path if the user shell is the bourne shell (/bin/sh) or the bash shell (/bin/bash), after these commands are entered sudo will work without using the full path:

PATH=$PATH:/usr/sbin:sbin

export PATH

If you don't want to type them in every time add them to the end of your .profile or .bashrc file for the user in question.






RHCE, VCP

Blog: http://computing.dwighthubbard.info

RHCE, VCP Blog: http://computing.dwighthubbard.info

View solution in original post

Reply
0 Kudos
6 Replies
mcowger
Immortal
Immortal
Jump to solution

What exactly are you running?

You may need to add something to your $PATH

--Matt

--Matt VCDX #52 blog.cowger.us
Reply
0 Kudos
thickclouds
Enthusiast
Enthusiast
Jump to solution

vdf or esxcfg-nics -l

standard commands

Charlie Gautreaux vExpert http://www.thickclouds.com
Reply
0 Kudos
rossb2b
Hot Shot
Hot Shot
Jump to solution

try

sudo /usr/sbin/esxcfg-nics -l

mittim12
Immortal
Immortal
Jump to solution

Try su - as well. The - makes the shell a login shell

If you found this or any other post helpful please consider the use of the Helpfull/Correct buttons to award points

Reply
0 Kudos
mcowger
Immortal
Immortal
Jump to solution

I would highly advise avoiding su - if possible (it isn't always possible though), as it does not provde any audot trail of what was run like sudo does.

--Matt

--Matt VCDX #52 blog.cowger.us
dwight
Enthusiast
Enthusiast
Jump to solution

Sudo runs a command as root but doesn't use the root user's environment settings. Specifically the root user's path normally searches the /sbin and /usr/sbin directories and a by default normal users do not. Since those directories contain the commands you mentioned they won't work in sudo without specifying the full path to the command.

The following commands will add the appropriate directories to the search path if the user shell is the bourne shell (/bin/sh) or the bash shell (/bin/bash), after these commands are entered sudo will work without using the full path:

PATH=$PATH:/usr/sbin:sbin

export PATH

If you don't want to type them in every time add them to the end of your .profile or .bashrc file for the user in question.






RHCE, VCP

Blog: http://computing.dwighthubbard.info

RHCE, VCP Blog: http://computing.dwighthubbard.info
Reply
0 Kudos