Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Linux Commands»Adding User in Secondary Group using Command in Linux

    Adding User in Secondary Group using Command in Linux

    By RahulJuly 7, 20211 Min Read

    Secondary groups are the groups that users added after the creations. The primary groups are created during the user creation process. In order to the permissions, there is no difference between them.

    Advertisement

    This quick tutorial helps you to add an existing user to a secondary group in Linux via the command line.

    Example

    Use the usermod command-line tool to assign a user to a secondary group. Here you can define multiple group names separate them by a comma.

    The following command will add jack to sudo group.

    usermod -a -G sudo jack 
    

    To make sure, check the entry in /etc/group file.

    cat /etc/group | grep "sudo" 
    

    Remove User from Secondary Group

    If in case, you have accidentally added a user to a different group or you want to remove another user from the group. The following command will remove user "jack" from the group "sudo".

    sudo gpasswd  -d jack sudo 
    

    gpasswd group usermod
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Top 10 JQ Commands Every Linux Developer Should Know

    How to Check if a Program Exists in Linux

    How to Create a Directory If It Does Not Exist in Linux

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to List Manually Installed Packages in Ubuntu & Debian
    • 10 Bash Tricks Every Developer Should Know
    • How to Validate Email Address in JavaScript
    • Firewalld: Common Firewall Rules and Commands
    • 12 Apk Commands in Alpine Linux Package Management
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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