How to Add a User to Sudoers in Ubuntu

The Privilege Escalation Vector

When you create a brand new user account on an Ubuntu server, the operating system inherently restricts that user to a localized, non-destructive environment. They cannot install software, restart system daemons, or modify network configurations. If this new user is actually a junior system administrator who requires the ability to execute these high-level commands, you must explicitly grant them permission to invoke the `sudo` (superuser do) command, effectively granting them temporary root access.

How to Add a User to Sudoers

The Ubuntu kernel manages administrative permissions by maintaining a specific, highly protected user group named `sudo`. Any user mathematically added to this group is instantly granted full administrative capabilities.

1. Open your terminal application or connect to the server via SSH.
2. You must execute this command from an account that already possesses root privileges.
3. You must utilize the `usermod` utility. The syntax requires the append flag (`-a`), the group flag (`-G`), the name of the target group (`sudo`), and finally the target username. Type the following command carefully, replacing `johndoe` with the actual username:

sudo usermod -aG sudo johndoe

4. Command Breakdown:
* -a (Append): This is absolutely critical. It tells the system to add the user to the new group without removing them from their existing groups. If you forget the `-a`, the user will be ripped out of all their current groups and placed solely in the sudo group, causing massive permission errors.
* -G (Group): Specifies the target group name.

5. Press Enter. If the command is successful, the terminal will simply return a blank prompt.
6. The Execution Reality: The permission matrix is updated instantly at the kernel level. However, if `johndoe` is currently logged in via SSH, he will not possess the new privileges. The user must entirely terminate their active terminal session and log back in for the new group membership to take effect.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.