Adding a user to the Sudoers list in Ubuntu 14.04

Posted May 17, 2014 44.7k views
I run: visudo and I'm presented with a blank file. I read a Digital Ocean article on this and apparently there is supposed to be something in here that I can replicate for my main user account. While I am not completely new to running a Linux system, I haven't done it in awhile & I certainly have never used a VPS before where I need to configure this. Figured I would ask here first before I totally just bomb my box and have to start over :p

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 answers
Try to re-install the package sudo. If this don't work try enter these in the file manually

# This file MUST be edited with the 'visudo' command as root.
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
# See the man page for details on how to write a sudoers file.
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification

# Allow members of group sudo to execute any command

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
If you're already running as root, check to see if the sudoers file exists by typing in:

ls /etc/sudoers

That will kick the file listing out if the file exists. If you have the file available, go with:

# vi /etc/sudoers

You should be able to get to 'insert' mode by pressing 'i' and you will see a notice about it being a read-only file (disregard that since you will be root), enter in the new user, hit escape, and force the file to save by entering in ':wq!'

Hope that helps.

As a root perform:

Step 1: adduser demo
Step 2: gpasswd -a demo sudo
Step 3: passwd demo


by Justin Ellingwood
When you start a new server, there are a few steps that you should take every time to add some basic security and set a solid foundation. In this guide, we'll walk you through the basic steps necessary to hit the ground running with Ubuntu 14.04.