How to Add a Sudo User on AlmaLinux 9.2 (Turquoise Kodkod): A Step-by-Step Guide

As a system administrator, one of the essential tasks in managing a Linux server is granting users administrative privileges through the "sudo" command. AlmaLinux, a robust and secure Linux distribution, follows the same principles as other CentOS/RHEL-based systems for managing users and permissions. In this tutorial, we'll walk you through the process of adding a sudo user on AlmaLinux 9.2.

Step 1: Connect to Your AlmaLinux Server

To get started, you need to access your AlmaLinux server via SSH or through the server's physical console. Ensure you have root or administrative access to execute commands.

Step 2: Log in as Root

Log in to your server as the root user or switch to the root user using the following command:

su -

Step 3: Create a New User

To create a new user, use the "useradd" command followed by the desired username. For example, let's create a user named "myuser":

useradd myuser

Step 4: Set a Password for the New User

Next, you need to set a password for the newly created user. Use the "passwd" command followed by the username:

passwd myuser

You'll be prompted to enter and confirm the new password for the user.

Step 5: Grant Sudo Privileges

To grant sudo privileges to the user, you need to add the user to the "wheel" group. On AlmaLinux, members of the "wheel" group have sudo access by default.

Use the "usermod" command to add the user to the "wheel" group:

usermod -aG wheel myuser

Step 6: Verify Sudo Access

To ensure that the user has been granted sudo privileges correctly, you can switch to the user's account using the "su" command:

su - myuser

Try running a command with sudo to check if the user has the necessary permissions:

sudo ls /root

If the user has been set up correctly, you should be prompted to enter the user's password, and the "ls" command will execute successfully.

Step 7: Update SSH Configuration (Optional)

If you wish to allow the new sudo user to log in directly via SSH, you might need to adjust the SSH configuration.

Open the SSH configuration file using a text editor (e.g., nano or vim):

nano /etc/ssh/sshd_config

Locate the line that says "PermitRootLogin yes" and change it to "PermitRootLogin no" to disable direct root logins:

PermitRootLogin no

Save the file and exit the text editor.

Step 8: Restart SSH Service (Optional)

After updating the SSH configuration, restart the SSH service to apply the changes:

systemctl restart sshd

Conclusion

Congratulations! You have successfully added a sudo user on your AlmaLinux 9.2 server. The new user now has administrative privileges and can execute administrative commands with the "sudo" command.

Remember to manage your users and permissions carefully to maintain the security and stability of your system. Grant sudo access only to trusted users who require administrative capabilities.

Now you can confidently manage your AlmaLinux 9.2 server with a dedicated sudo user, keeping your system secure and well-organized. Happy server administration!


Comments

Popular posts from this blog

How to Create Hyperlink on Blogger Post

How to Check AlmaLinux Version on the Command Line: A Quick Guide