How To Setup New User on CentOS 7

How To Setup New User on CentOS 7

This guide will walk you through the process of setting up new User on a CentOS 7 with Sudo privileges.

Prerequisites

Before diving into the process of creating a user on CentOS, ensure the following prerequisites are met:

  • Access to a CentOS server

  • Sudo privileges

  • Basic understanding of Linux commands

Step-by-Step Guide:


1. Log in as a Sudo User:

sudo su -

This command allows you to log in as a sudo user.

2. Create a New User:

Switch to the root user to have the necessary permissions for Ansible tasks.

useradd <username>

Replace <username> with the desired name for your new user.

3. Set Password for the New User:

passwd <username>

Choose a secure password for the new user.

4. Add User to the Wheel Group:

usermod -aG wheel <username>

Granting wheel group access provides sudo privileges to the user.

5. Switch to the New User:

This command allows you to access the system as a newly created user.

su - <username>

6. Switch Back to Root User:

To return to the root user from the new user session.

su -

7. Check Sudo Privileges:

Verify sudo privileges for the new user by checking the contents of the /root directory.

sudo ls -l /root

Frequently Asked Questions (FAQ):

  1. Why should I create a new user on CentOS?

Creating a new user provides a more secure way to manage and perform tasks on your CentOS system, as using the root user for everyday tasks poses security risks.

  1. What is the purpose of the wheel group?

The wheel group is used to grant sudo (superuser) privileges to a user. Adding a user to the wheel group allows them to execute administrative commands with elevated privileges.

  1. Can I skip creating a new user and use the root user directly?

While possible, it is not recommended to use the root user for regular tasks due to security concerns. Creating a new user with sudo privileges is a best practice.

  1. Can I skip creating a new user and use the root user directly?

The main dependency is having Sudo privileges. Ensure that you are logged in as a user with sudo access before attempting to create a new user.

  1. How can I verify that the new user has Sudo privileges?

You can check sudo privileges by running sudo ls -l /root. If you can view the contents of the /root directory without errors, the new user has sudo privileges.

  1. Basic Linux Command Knowledge:

Users should have a basic understanding of Linux command-line operations, as some commands like ls, cd, sudo, and vim are used in the documentation.

By following these steps, you can efficiently create a new user on CentOS with sudo privileges, enhancing the security and manageability of your system.

Did you find this article valuable?

Support ParaNerdOps by becoming a sponsor. Any amount is appreciated!