How to enable sudo on a user account on Debian
sudo(i.e. Super-user do) allows some users to execute some commands as root (or another user). According to Debian Wiki, using
sudo is better (safer) than opening a session as root for a number of reasons, including:
- Nobody needs to know the root password (sudo prompts for the current user’s password). Extra privileges can be granted to individual users temporarily, and then taken away without the need for a password change.
- It’s easy to run only the commands that require special privileges via sudo; the rest of the time, you work as an unprivileged user, which reduces the damage that mistakes can cause.
- Auditing/logging: when a sudo command is executed, the original username and the command are logged.
Now let’s see how we can enable
sudo on a freshly-installed Debian machine.
01) First, open up your terminal and get the root access:
02) Now install
apt-get install sudo
03) Then, add the user account in which you need to use the
adduser username sudo
04) Logout from the root user session:
05) Reboot your VM for changes to take place on the system.
06) Now your user account must have the
sudo access. Feel free to try it:
sudo echo "Hello"