How to add user to sudo group in a Linux VPS?

With Sudo you can provide special privileges to any user or group. In Linux, there are few commands which can be accessible with root user only. You can authorize the required user who can run those commands with sudo. Reboot command can be run only by root user or sudo user.

Following are the steps to enable passwordless sudo for User.

  1. Login to your Linux server with root user using ssh.

  2. Let us create a user. Here, we will create test user.

    # adduser test
  3. Set Password for user test.

    New password:
    Retype new password:
    passwd: all authentication tokens updated successfully.

Add Users to Sudo Group

In Centos, there will be a group named "wheel". All the user accounts added to this group will have sudo privileges automatically. We can add our user in wheel group. This is the easiest and quick solution to provide sudo privilege.

  1. Let us check if wheel group is enabled on server.

  2. Type below command to open the configuration file.

    # sudo visudo
  3. You need to uncomment the %wheel line as per the below screen capture to enable wheel group.

    # Allows people in group wheel to run all commands
    %wheel ALL=(ALL) ALL
  4. Add user test to wheel group.

    # usermod -aG wheel test
  5. To verify the new user with sudo privileges, login with the test user and run the below command.

    # sudo whoami

          It should provide the below output if user is added with sudo privilege, it will provide the below output.

# Output
root

          This is how you can provide sudo privilege to any of the users in Centos.

          Facing an issue with su user? Please refer to SU > Enable Cagefsctl for more details.

Related Articles

How to Install OpenJDK JAVA 11/8 on Ubuntu?

You can follow this tutorial to install JAVA OpenJDK in all the Ubuntu versions. Following are...

The action Install for product MySQL Server 5.7.19 failed.

You may face this error while installing MySQL 5.7 or upgrading MySQL 5.6 to 5.7. Here, is the...

How to install Google Chrome on Ubuntu 18.04 using the Command Line?

Following are the steps to install Google Chrome using Command-Line. Edit the source.list file...

How to kill a process on Linux using command?

There might be an issue with applications that can be hung and not working properly. In this...

How to find all files/folders with 777 permission in Linux?

First of all, let us understand the meaning of 777 file permission in Linux. Suppose, any of the...

  • 0 Users Found This Useful

Was this answer helpful?