no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


sudo [2016/02/02 00:15] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== sudo ======
  
 +Use ''vim'' to edit sudo:
 +
 +<code>
 +EDITOR=vim visudo
 +</code>
 +
 +On Ubuntu, set the default editor:
 +
 +<code>
 +sudo update-alternatives --config editor
 +</code>
 +
 +Display sudo commands the user can run:
 +
 +<code>
 +sudo -l
 +</code>
 +
 +Run a command as a specific user:
 +
 +<code>
 +sudo -u beandog -- whoami
 +</code>
 +
 +Switch to another user:
 +
 +<code>
 +sudo -u beandog -s
 +</code>
 +
 +=== Syntax ====
 +
 +<code>
 +<user/group> <hostnames>= [(<users>)] [NOPASSWD: [ALL|/usr/bin/command,/usr/bin/command2]]
 +</code>
 +
 +=== Examples ===
 +
 +Let user alan run rdiff-backup as another user, not requiring a password:
 +
 +<code>
 +alan ALL= (clientuser) NOPASSWD: /usr/bin/rdiff-backup
 +</code>
 +
 +Let user alan run one command as root:
 +
 +<code>
 +alan ALL= NOPASSWD: /usr/sbin/backup-manager
 +</code>
 +
 +Allow user ''steve'' to run any command as user ''beandog'' without asking for password:
 +
 +<code>
 +steve ALL=(beandog) NOPASSWD: ALL
 +</code>
 +
 +Set PATH for new user. sudo will not pass the user's PATH when switching to another user by default, which can cause problems if calling binaries in /usr/local. Override it with the secure_path option.
 +
 +<code>
 +Defaults secure_path = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 +</code>

Navigation
QR Code
QR Code sudo (generated for current page)