How to Add User to Sudoers File on Ubuntu / Debian

Sudo is a program that allows users to run programs with the security privileges of another user (normally the superuser, or root). The /etc/sudoers file controls who can run what commands as what users on what machines and can also control special things such as whether you need a password for particular commands.

To add user to sudoers file, execute this command:

$ sudo visudo

And create new line at the bottom of file:

pikachu   ALL=(ALL)  ALL

Above line will allow user pikachu to run any command on any host as any user.

The structure is HOST=(USER) COMMAND

Another configuration example:

User_Alias     OPERATORS = joe, mike, jude
Runas_Alias    OP = root, operator
Host_Alias     OFNET =
Cmnd_Alias     PRINTING = /usr/sbin/lpc, /usr/bin/lprm

# The users in the OPERATORS group can run any command from any terminal.

linus ALL=(OP) ALL
# The user linus can run any command from any terminal as any user
in the OP group (root or operator).

# user user2 may run any command from any machine in the  OFNET network,
as any user.

# user user3 may run lpc and lprm from any machine.

go2linux ALL=(ALL) ALL
# user go2linux may run any command from any machine acting as any user.


Leave a Reply

Your email address will not be published. Required fields are marked *