I tested the group-based and file-based ways to add a user to sudoers on a current Debian-family system, including syntax validation with visudo and permission checks with sudo -l. Use the sudo group for a normal administrator, and use a sudoers.d rule when you need narrower or separately managed access.
Choose the method that matches the access you need
Ubuntu and Debian already define the sudo group for full administrative access. Adding a user to that group is the shortest path, while a user rule or group rule in sudoers.d gives you a separate file that visudo can validate before sudo reads it.
- learn how Linux users, groups, and permissions fit together
- use chmod and chown to change file permissions and ownership
- change a username safely on Ubuntu
- compare common Linux shells before changing a login shell
- separate interactive shell settings from system-wide configuration
- Check the user and group model before changing permissions
- Review file ownership and mode changes with chmod and chown
- Check the account name before changing it
Before you change sudo access
You need an account that already has sudo access or a root shell. Keep one privileged terminal open while you test the new account, because a syntax mistake in sudoers can block later administrative commands.

Add a user to the sudo group
Use this method when the user should receive the same broad administrative access as the existing sudo group. The -a flag appends the group, so it does not discard the user’s current supplementary groups.
sudo usermod --append --groups sudo username
Replace username with the account name and start a new session so the shell loads the group membership.
id username
getent group sudo
The first command shows the account’s supplementary groups, while the second shows the members of the sudo group.

Use adduser when you prefer an interactive wrapper
Debian-family systems also provide adduser as a friendlier wrapper around common account administration. It asks for the account name and confirms the group change instead of requiring the full usermod option set.
sudo adduser username sudo
This command changes group membership, not the sudoers policy itself. Test the result from a new login session, then run a harmless command through sudo.
Edit sudoers safely with visudo
Edit the main policy only when you need a direct user rule or a group rule that differs from the default sudo group. Always open it with visudo because it locks the file and checks the syntax before saving.
sudo visudo

A full user rule follows the same structure as the root rule, with username replaced by the account you are granting access to.
username ALL=(ALL:ALL) ALL

The first ALL selects every host, the run-as list allows the user to act as any user and group, and the final ALL allows every command. That is broad authority, so use a command-specific rule when full administration is not required.

Create a separate sudoers.d rule
A file in sudoers.d keeps an account or team rule separate from the main policy. This is easier to review and remove, and it avoids editing a long shared file for a single account.
sudo visudo --file=/etc/sudoers.d/username
Add one policy line, then save and exit. Use a filename with only letters, numbers, underscores, and hyphens because sudo skips filenames containing a dot or ending in a tilde.
username ALL=(ALL:ALL) ALL
If the same access should apply to a group, prefix the group name with a percent sign. The rule below grants every member of admins full sudo access.
%admins ALL=(ALL:ALL) ALL

Validate the rule before testing it
Use visudo in check mode before you rely on a new file. This catches malformed policy syntax without changing the active sudoers configuration.
sudo visudo --check --file=/etc/sudoers.d/username
Then inspect the effective privileges for the account. The -U option asks sudo to list privileges for another user, which is useful when you are testing from an existing administrator session.
sudo -l -U username
A new login session is still required after a group change. If the user receives a permission error, confirm the group with id, start a fresh session, and check that the sudoers.d filename and permissions are valid.
Remove sudo access when it is no longer needed
Remove a user from the sudo group when that group membership supplied the access. The -r flag removes only the named supplementary group.
sudo gpasswd --delete username sudo
For a direct user rule, remove the rule from sudoers with visudo. For a dedicated sudoers.d file, delete that file only after checking that no other access depends on it.
sudo visudo --file=/etc/sudoers.d/username
Common failure points
Command not found: install the sudo package for your distribution or use the package manager’s documented package name. Permission denied: run the administration command from an account with existing sudo or root access. Changes do not appear: start a new login session after changing group membership.
Frequently asked questions
Should I add a user to the sudo group or edit sudoers?
Add the user to the sudo group when they need broad administrator access. Edit a sudoers or sudoers.d rule when you need command-specific access or a separately managed policy.
Why does a sudo group change not work immediately?
Group membership is loaded when the session starts. Log out and back in, or open a new login session, then confirm the group with id username.
Why should I use visudo?
visudo locks the policy while it is edited and checks the syntax before saving. That reduces the chance of leaving sudo with an unreadable configuration file.
Use the sudo group for ordinary administrator access, and reserve direct sudoers rules for cases where the command scope or policy needs to be explicit. Validate every policy file with visudo before you close the privileged session.
