Can't perform root command by using Sudo
Hi All, I am using Redhat8 and try to permit root command to user "ken" by using sudo, i have edited visudo and try to test it but fail. What's wrong ?
[root@localhost /]# visudo # sudoers file. # Host alias specification # User alias specification # Cmnd alias specification # Defaults specification # User privilege specification root ALL=(ALL) ALL ken ALL=(ALL) ALL # Uncomment to allow people in group wheel to run all commands # %wheel ALL=(ALL) ALL [ken@localhost tracy]$ sudo service xinetd restart sudo: service: command not found [ken@localhost tracy]$ sudo init 0 sudo: init: command not found |
That has nothing to do with permissions, the programs just aren't in your path. Try using the full path to the programs.
You can add aditionsal paths to your PATH with: PATH="/path/to/new/path:"$PATH |
but i have go into the path and try again. Also fail.
[ken@localhost init.d]$ sudo service xinetd restart Password: sudo: service: command not found |
What happens if you use the full path:
sudo /sbin/service xinetd restart |
Yes, it work Thank you very much !!!
but why I can't go into that path then restart it ? |
Hello,
please note that you can also use sudo -i <command>. |
sudo opens up a new shell with your current path, with elevated privs as per sudoers file.
Normally (and for good security), the current dir (ie '.') is NOT in your path, otherwise a hacked prog in your 'current' dir could be run by you with elevated privs. Always use full path for cmds called via sudo, or specify the cmd in the sudoers file (better/more secure). |
All times are GMT -5. The time now is 09:23 PM. |