sudo

Check syntax of an arbitrary sudo-file (one you might want to put into the /etc/sudoers.d directory):

visudo -cf sudoers.test

sudoers

The following grants root priveleges to the user johndoe, allowing him to execute anything as root via sudo, without beeing asked for a password.

johndoe ALL=(ALL) NOPASSWD: ALL

Pipe - or Redirect Output

If you need to redirect output oder pipe commands together you can make it work with a subshell:

sudo sh -c 'ls -la /root/ > /root/ls.txt'

SSH Agent Forwarding with Sudo

If you want to use your current user's SSH agent forwarding with sudo (to become root) this is one possible way to do this:

visudo -f /etc/sudoers.d/05_root
/etc/sudoers.d/05_root
Defaults>root env_keep+=SSH_AUTH_SOCK

This way root (and only root) is allowed to reuse your SSH agent socket while you sudo. This will greatly enhance your sudo-experience :-)

linux/sudo.txt · Last modified: 2015-05 by tb
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready