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

Collapse

Unconfigured Ad Widget

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Annie_P
    Member
    • Aug 2022
    • 88

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

    How to add a user to the sudo group in a Linux VPS?
  • Rex Maughan
    Senior Member
    • Mar 2022
    • 112

    #2
    Hello Annie_P,


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

    Below given are the steps to enable passwordless sudo for User:
    • Login to your Linux server with the root user using ssh.
    • Let us create a user. Here, we will create a test user.

    Code:
    # adduser test
    • Set Password for user test.

    New password:

    Retype new password:

    passwd: all authentication tokens updated successfully.
    • Now, add the above user to the Sudo Group:
    There will be a group named "wheel" in Centos. Any user accounts added to this group will hold sudo privileges automatically. Therefore, we can add our user to the wheel group for giving sudo privileges to a user. It is the easiest and quick solution to give sudo privilege.
    • Check if the wheel group is enabled on the server.
    • Type the below command to open the configuration file,

    Code:
    # sudo visudo
    • You need to uncomment the %wheel line by removing the # sign to enable the wheel group.
    Note: If the %wheel is not commented, keep it as it is.


    # will allow peoples in group wheel to run all commands

    Code:
    %wheel ALL=(ALL) ALL

    Add user test to the wheel group:

    Code:
    # usermod -aG wheel test

    To verify the new user with sudo privileges, log in with the test user and run the below command,

    Code:
    # sudo whoami

    It should provide the below output; if a user is added with sudo privileges,


    Code:
    # Output
    
    root
    Thus, it is how you can provide sudo privilege to any users in Centos. I hope the information above will be helpful for you in adding a user to the sudo group.

    -----------------------
    Regards,
    Rex Maughan

    Comment

    Working...
    X