In this tutorial, we will guide you through the process of creating a new user and giving them sudo privileges on a Linux system.
Step 1: Create a New User
To create a new user, use the useradd
command:
Code copied to your clipboard!
Step 2: Set a Password for the New User
Next, set a password for the newly created user:
Code copied to your clipboard!
Step 3: Add the User to the Sudoers Group
To grant the new user sudo privileges, add them to the sudo
group:
Code copied to your clipboard!
Step 4: Verify the User's Sudo Access
To check if the user has been added to the sudoers group successfully, use the following command:
Code copied to your clipboard!
Conclusion
You've successfully created a new user and granted them sudo privileges. The new user can now execute commands as a superuser by prefixing commands with sudo
.