How to Create a Sudo User on CentOS Stream

Learning to create a sudo user on CentOS Stream is fundamental to ensuring secure and efficient system management. The sudo user acts as a protective layer, granting administrative privileges without exposing the system to potential risks associated with the root user. In this introduction, we’ll delve into the significance of a sudo user and the steps to set one up on CentOS Stream 9 or its older enterprise-base release of CentOS Stream 8.

Understanding the Sudo User on CentOS Stream:

  • Administrative Access: A sudo user can execute commands with administrative privileges, allowing them to manage system settings, install software, and perform other critical tasks.
  • Safety Net: Unlike the root user, a sudo user operates within a controlled environment. This minimizes the chances of unintentional system disruptions.
  • Audit Trail: Actions performed using sudo are logged, providing a clear record of changes made, which aids in troubleshooting and accountability.
  • Flexibility: System administrators can define specific permissions for sudo users, ensuring they have just the right amount of access needed for their tasks.

Why Use a Sudo User on CentOS Stream?:

  • Enhanced Security: By minimizing direct root access, the system is less vulnerable to both internal mistakes and external threats.
  • Best Practices: Creating a sudo user aligns with industry best practices for system administration, promoting a standardized approach.
  • Ease of Use: Using sudo is a familiar and consistent system management method for those transitioning from other Linux distributions.

Establishing a sudo user on CentOS Stream is a proactive measure to maintain system integrity while facilitating administrative tasks. The subsequent sections will guide you through creating a sudo user on CentOS Stream, ensuring a secure and streamlined experience.

Switch To Root Account on CentOS Stream

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.

Create a New User on CentOS Stream

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.

Set a Password For New User on CentOS Stream

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.

Add User to Sudo Group on CentOS Stream

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

Test Sudo Privileges on CentOS Stream

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.

Leave a Comment