To add user privileges in Linux, particularly for granting sudo access, follow these steps:
-
Open the Terminal.
-
Use the
usermodCommand: To add a user to thesudogroup (which grants them sudo privileges), use the following command:sudo usermod -aG sudo usernameReplace
usernamewith the actual username of the user you want to grant privileges to. -
Verify Group Membership: You can check if the user has been added to the
sudogroup by running:groups username -
Edit the Sudoers File (Optional): If you want to specify more granular permissions, you can edit the
/etc/sudoersfile usingvisudo:sudo visudoAdd a line for the user or group, for example:
username ALL=(ALL) ALL -
Save and Exit: If you edited the sudoers file, save your changes and exit the editor.
-
Test the Configuration: Have the user log out and back in, then test by running a command with
sudoto ensure they have the expected privileges.
By following these steps, you can successfully add user privileges in a Linux environment.
