Javascript required
Skip to content Skip to sidebar Skip to footer

How to Add Second Account to Family Group Switch

Introduction

The sudo command stands for "Super User DO" and temporarily elevates the privileges of a regular user for administrative tasks. The sudo command in CentOS provides a workaround past assuasive a user to elevate their privileges for a single job temporarily.

This guide will walk you through the steps to add a user to sudoers in CentOS.

Tutorial on how to create a sudo user on CentOS 7.

Prerequisites

  • A organisation running CentOS 7
  • Access to a user account with root privileges

Note: Linux Sudo Command tutorials likewise available for Debian and Ubuntu.


Add User to Sudoers on CentOS

Stride one: Login every bit Administrator

If yous're working on a local machine, log in to the system with administrator credentials.

If you're connecting to a remote automobile (over a network), open a terminal window and enter the command:

          ssh [email protected]_ip_address        

The server_ip_address is the network IP address of the server you're logging into. Enter your credentials when prompted.

Step 2: Create a New Sudo User

To add a new sudo user, open the terminal window and enter the command:

          adduser UserName        

Use the bodily username for your new user in place of UserName .

Adjacent, create a password for the new user by entering the following in your final window:

          passwd UserName        

The organisation should brandish a prompt in which you can set and ostend a countersign for your new user business relationship. If successful, the system should respond with "all authentication tokens updated successfully."

How to Add together Users to Sudo Grouping

By default, CentOS 7 has a user group chosen the "wheel" group. Members of the bike group are automatically granted sudo privileges. Adding a user to this group is a quick and easy way to grant sudo privileges to a user.

Step 1: Verify the Cycle Group is Enabled

Your CentOS 7 installation may or may not have the cycle group enabled.

Open up the configuration file past entering the command:

          visudo        

Ringlet through the configuration file until you see the post-obit entry:

          ## Allows people in group wheel to run all commands  # %cycle        ALL=(ALL)       ALL        

If the 2d line begins with the # sign, it has been disabled and marked as a comment. Just delete the # sign at the beginning of the 2d line so it looks like the post-obit:

          %cycle        ALL=(ALL)       ALL        

Then save the file and get out the editor.

Annotation: If this line didn't get-go with a # sign, y'all don't need to make whatsoever changes. The wheel group is already enabled, and you lot can shut the editor.


Annotation: If this line didn't kickoff with a # sign, y'all don't need to make any changes. The wheel group is already enabled, and you can shut the editor.


Step 2: Add User to Group

To add a user to the wheel group, use the command:

          usermod –aG bike UserName        

Equally usual, supervene upon UserName with the name of the user receiving sudo privileges.

Step: 3 Switch to the Sudo User

Switch to the new (or newly-elevated) user business relationship with the su (substitute user) control:

          su - UserName        

Enter the countersign if prompted. The terminal prompt should alter to include the UserName.

Enter the following command to listing the contents of the /root directory:

          sudo ls -la /root        

The final should request the password for UserName. Enter it, and you should see a brandish of the list of directories. Since list the contents of /root requires sudo privileges, this works as a quick style to prove that UserName can use the sudo command.

Alternative: Add User to Sudoers Configuration File

If there's a problem with the wheel group, or administrative policy prevents you from creating or modifying groups, you can add together a user directly to the sudoers configuration file to grant sudo privileges.

Step 1: Open the Sudoers File in an Editor

In the terminal, run the following command:

          visudo        

This will open the /etc/sudoers file in a text editor.

Step 2: Add the New User to file

Gyre downwards to detect the post-obit section:

          ## Allow root to run any commands anywhere  root ALL=(ALL) ALL        

Right afterwards this entry, add together the following text:

          UserName ALL=(ALL) ALL        

Replace UserName with the username you lot created in Pace 2. This section should expect like the following:

          ## Allow root to run any commands anywhere  root ALL=(ALL) ALL  UserName ALL=(ALL) ALL        

Save the file and get out.

Pace 3: Test Sudo Privileges for the User Account

Switch user accounts with the su (substitute user) command:

          su — UserName        

Enter the password for the account, if prompted. The terminal prompt should alter to include UserName.

List the contents of the /root directory:

          sudo ls —la /root        

Enter the password for this user when prompted. The last should display a list of all the directories in the /root directory.

Decision

This guide showed you how to add a user to sudoers in CentOS or modify the privileges of an existing sudo user .

The Linux sudo command is critical for running advanced and administrative tasks on a Linux system. While this could be done using a root user (or administrator account) using the su command, arrangement administrators advise against operating permanently in a root account. Not simply tin can it exist a security risk, but it can too allow changes to a Linux system that can intermission functionality.

Was this article helpful?

Yeah No

macgroartymorce1994.blogspot.com

Source: https://phoenixnap.com/kb/how-to-create-add-sudo-user-centos