Formatting code for LinuxSudo


show source only

{{parent page="Linux"}}

===SUDO===
Sudo allows a non-root user to execute programs as root.

==/etc/sudoers==
This file defines who can sudo. admin will be able to sudo by supplying the root password, while superuser can sudo without a password.
%%
# Allow root to run any commands anywhere
admin ALL=(ALL) ALL
superuser ALL=NOPASSWD: ALL

# Allow user to run certain commands w/o password
Cmnd_Alias BASHSOUND = /bin/bash, /usr/local/bin/cmictl
smith ALL=(ALL) NOPASSWD: BASHSOUND, PASSWD:/usr/bin/tcsh

# command with arguments
jane ALL=(ALL) NOPASSWD: /usr/bin/vi /etc/passwd
%%

Another example to allow sudo to another user, other than root:
%%
smith ALL = (testusr) NOPASSWD: /testsudo.sh
%%

To run, do this:
%%
sudo -u testusr /testsudo.sh
%%

==sudo bash==
On systems where su cannot be granted, sudo is a good alternative. Simply do a sudo bash gives you virtually the same thing as "su -"
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki