Sudo (short for “Super User Do”) allows regular users to execute commands with root privileges on a Debian system. This is essential for system administration tasks without requiring users to constantly log in as root.
1. Edit the sudoers File:
-
Open the sudoers file using the visudo
command:

visudo
is specifically designed for editing the sudoers file. It ensures proper syntax and prevents accidental corruption.
-
Locate the %sudo
group: Find the line that defines the %sudo
group. This group typically includes users who are granted sudo privileges.
-
Add the desired user to the %sudo
group: Add the username of the user you want to grant sudo permissions to within the %sudo
group definition. For example:

would become:
-
Save and exit: Press :wq
(write and quit) to save the changes and exit the editor.
2. Verify Sudo Permissions:
-
Log out and log back in as the user you granted sudo permissions to.
-
Attempt to execute a command with sudo:
You should be prompted for the user’s password. If the command executes successfully, sudo permissions have been granted correctly.
Important Notes:
- Use
visudo
: Always use visudo
to edit the sudoers file. This prevents accidental corruption and ensures proper syntax.
- Grant sudo permissions judiciously: Only grant sudo permissions to users who absolutely require them.
- Regularly review sudoers configurations: Periodically review the sudoers file to ensure that only authorized users have sudo privileges.
0 Comments