CentOS Stream is a popular Linux distribution used by many servers. One of the most important features of CentOS Stream is the ability to create a sudo user, which is a regular user with administrative privileges. This article will show you how to create a sudo user on CentOS Stream using the terminal method, which is perfect for beginners.
Table of Contents
What is a Sudo User?
Before diving into the tutorial, it’s essential to understand what a sudo user is and why creating one is necessary. A sudo user is a regular user who is authorized to perform administrative tasks on the system using the “sudo” command. This user has limited access to the system, ensuring they cannot accidentally damage it. In contrast, a root user has full control over the system and can cause irreversible damage if not used carefully.
Step 1: Creating a Sudo User
Follow these simple steps to create a sudo user on CentOS Stream. First, switch to the root user to execute the commands to create a new user. You can do this by typing the following command:
su
You will be prompted to enter the root user’s password. After you enter the correct password, you will be logged in as the root user.
Step 2: Create a New User
Now you can create a new user using the “useradd” command. For example, to create a user named “johndoe,” you can use the following command:
sudo adduser <example username>
This command creates a new user with the name “johndoe,” and the “-m” option creates a home directory for the new user.
Step 3: Set a Password
After creating the new user, you need to set a password for them using the “passwd” command. For example, to set the password for the “johndoe” user, you can use the following command:
sudo passwd johndoe
You will be prompted to enter and confirm the new password for the user.
Step 4: Add User to Sudo Group:
To grant sudo privileges to the new user, you must add them to the “wheel” group, which has sudo access by default on CentOS Stream. You can add the user to the “wheel” group using the following command:
sudo usermod -aG wheel johndoe
Step 5: Test Sudo Privileges
To test the sudo user’s privileges, you can switch to the newly created user using the following command:
su johndoe
You will be prompted to enter the password for the “johndoe” user. After entering the correct password, you will be logged in as the “johndoe” user. You can now test the sudo privileges by running any command that requires sudo access. For example, you can update the system using the following command:
Conclusion
Creating a sudo user on CentOS Stream is a reliable and secure Linux distribution, and creating a sudo user is an essential step to managing your system efficiently. The terminal method discussed in this article is a beginner-friendly way to create a sudo user without manually editing the sudoers file. Following the steps outlined in this guide, you can create a new user with sudo privileges and ensure your system remains secure. Remember always to use strong passwords and limit sudo access to trusted users to prevent unauthorized access to your system.
Frequently Asked Questions
Q. What is a sudo user?
A. A sudo user is a regular user who is authorized to perform administrative tasks on the CentOS Stream system using the “sudo” command.
Q. Why do I need to create a sudo user on CentOS Stream?
A. Creating a sudo user allows you to grant administrative privileges to a regular user without giving them full access to the system. This helps to ensure the security and stability of your CentOS Stream system.
Q. Can I create a sudo user on CentOS Stream using the terminal method?
A. Yes, you can create a sudo user on CentOS Stream using the terminal method. Our guide outlines the steps you need to follow to create a new user with sudo privileges.
Q. Is it necessary to edit the sudoers file manually to grant sudo privileges on CentOS Stream?
A. No, it is unnecessary to manually edit the sudoers file to grant sudo privileges on CentOS Stream. You can use the terminal method outlined in this article to create a new users and grant them sudo privileges, and this method is beginner-friendly and easy to follow.