Adding User to the sudo Group
On Ubuntu, the easiest way to grant sudo privileges to a user is by adding the user to the “sudo” group. Members of this group can execute any command as root via sudo
and prompted to authenticate themselves with their password when using sudo
.
We’re assuming that the user already exists. If you want to create a new user, check this guide.
To add the user to the group run the command below as root or another sudo user. Make sure you change “username” with the name of the user that you want to grant permissions to.
usermod -aG sudo username
Granting sudo access using this method is sufficient for most use cases.
To ensure that the user has sudo privileges, run the whoami
command:
sudo whoami
You will be prompted to enter the password. If the user has sudo access, the command will print “root”:
root
If you get an error saying “user is not in the sudoers file”, it means that the user doesn’t have sudo privileges.
No comments:
Post a Comment