How-To: sudo on Debian

Sudo is a tool which allows users to execute specific commands as root (or another) user. Here's how you can install it on Debian:

Install package:

apt-get install sudo

Default /etc/sudoers file will be created during installation. Never edit this file directly. Instead, use visudo tool which you'll get with sudo package.
visudo checks for EDITOR and VISUAL environment variables, and if neither of them exists, it uses /usr/bin/editor, which is by default symlink to nano on debian.
If you want to use vi editor, execute this:

export VISUAL="vi"

Or, if you want to make the changes permanent for all users, add this to /etc/environment:


and run:

source /etc/environment

run visudo:


Add this line to the end of the file to enable sudo group, whose members will be able to execute all commands without entering root password:


add user to sudo group:

adduser {user} sudo

If you want to lock the root account:

passwd -l root

Useful tools / links