Facebook X (Twitter) Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook X (Twitter) Instagram
    TecAdmin
    You are at:Home»Linux Commands»How to Create a Sudo User in CentOS

    How to Create a Sudo User in CentOS

    By RahulJune 28, 20212 Mins Read

    Sudo allows us to provide superuser privileges to a normal user with restrictions. It allows users to run programs with the privileges of the superuser. You can configure sudo to give root privileges to specific commands only. Anyone working with the sudo privileges always remember a famous quote:

    With great power comes great responsibility

    This tutorial provides you the instruction to create a new user with Sudo privileges on CentOS and RHEL system. Also, help you to allow sudo access to the existing accounts or remove sudo privileges from any account.

    Creating User with Sudo Access

    The adduser is the default system command to create new users on your Fedora system. In Fedora systems, a default group is created with the name “wheel” having sudo privileges. So we can assign sudo privileges to any user by adding them to the wheel group.

    Let’s create a new user “tecadmin” and also add them to a group “wheel”.

    sudo adduser -G wheel tecadmin 
    

    Make sure to use -G in the capital, which is used for supplementary groups of the new account.

    Next, set a strong password for the new account.

    sudo passwd tecadmin 
    

    Assign Sudo Privileges to User

    Use the usermod command for making changes in the existing accounts. In this case, a user tecadmin already created on your system. Now add this user to a secondary group wheel. That will provide sudo privileges to your existing account.

    To add user to wheel group, type:

    sudo usermod -a -G wheel tecadmin 
    

    This will just add tecadmin user to the wheel group. One can verify the same in the /etc/group file.

    Remove Sudo Privileges from User

    The gpasswd is an command-line utility for managing /etc/groups and /etc/shadow. With the help of this command, you can add or remove any user from groups.

    Use the following command to remote remove tecadmin account from wheel group.

    sudo gpasswd -d tecadmin wheel 
    

    In case, you have made any direct entry made to /etc/sudoers file. Edit sudoers file with visudo command, search for the entry and comment that.

    Conclusion

    In this tutorial, we have discussed creating a Sudo account in the CentOS and RHEL systems. Additionally provides you the instructions to allow sudo access to the existing users. Also helps you to remove sudo privileges from the existing account.

    sudo user
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Increase Sudo Session Duration in Linux

    How to Ignore SSL Certificate Check with Wget

    How to Ignore SSL Certificate Check with Curl

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • Difference Between Full Virtualization vs Paravirtualization
    • Virtualization vs. Containerization: A Comparative Analysis
    • Using .env Files in Django
    • Using .env File in FastAPI
    • Setting Up Email Notifications for Django Error Reporting
    Facebook X (Twitter) Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.