sudo (“superuser do”) allows a regular user to run commands as another user — most often the root user, who has full administrative control. It’s safer than logging in as root directly because it grants temporary admin rights only when needed.
Why Debian Handles It Differently
Unlike Ubuntu, Debian doesn’t enable sudo for new users by default. Instead, Debian expects you to log in as root to perform administrative tasks.
During installation, you can:
- Set a root password — the traditional method, or
- Leave the root password blank — in that case, your user can use
sudoif added to the proper group.
How to Enable sudo on Debian
If you can log in as root, install sudo and add your user to the sudo group:
su
apt install sudo
usermod -aG sudo yourusername
Then log out and back in. Your user can now run administrative commands like:
sudo apt update
sudo apt install package
Testing and Troubleshooting
To verify that it works:
sudo whoami
If it prints root, you’re all set.
If you see “user is not in the sudoers file,” it means your user hasn’t been added to the sudo group or the configuration file is missing the correct line.
How Permissions Work
sudo checks the file /etc/sudoers and any files in /etc/sudoers.d/. On Debian, this line grants access to users in the sudo group:
%sudo ALL=(ALL:ALL) ALL
Edit sudo permissions safely using:
sudo visudo
This prevents syntax errors that could lock you out.
Tips
- Use
sudo -ito open a root shell (like logging in as root). - Use
sudo -kto invalidate cached credentials (forces password next time). - Only give trusted users
sudoaccess — it grants full system control.