Instructions to Add A User to the Sudoers File
These instructions are a companion piece to my educational posts on Ubuntu . They are intended for use on a personal Ubuntu Linux machine. You must know the root password to complete these instructions. If you are running these instructions on a machine other than your own personal machine, then confirm with your IT department that you have permissions to make changes to the sudoers file before attempting these instructions.
The sudo command is a command that allows users to run commands using administrative (root) privileges on Linux and Unix-like operating systems. The name of the command is a shortened version of “super user do”. By preceding a command with sudo, we tell the operating system we want to run the command with super user/root privileges. In order for a user other than the root user to do this, they must be added to the sudoers file.
The name of the
sudocommand is derived from “super user do”
The sudoers file is a configuration file in Linux and Unix-like operating systems. When a user runs the sudo command, Linux and Unix-like operating systems check this file to see if the user is authorized to gain root privileges. To allow users to execute sudo, the user must be added to the sudoers file. There are multiple ways to add the user.
Root level access is required to add a user to the sudoers file.
If your OS supports it, a user can be added to the sudoers file using the adduser command. If you came here from one the Archidevineer Ubuntu
tutorials, this command should work on the Ubuntu VM that you created. adduser is a user-friendly, high-level script that is common on Debian-based Linux distributions like Ubuntu.
- Gain root access by typing su -.
- Enter the root password when prompted.
- Type “adduser username sudo”. (Make sure to replace “username” with the actual name of your user.)
- Type “exit” and press enter to leave root access.