Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Linux Commands»Adding User in Secondary Group using Command in Linux

    Adding User in Secondary Group using Command in Linux

    RahulBy RahulNovember 26, 20141 Min ReadUpdated:July 7, 2021

    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.

    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
    Previous ArticleHow to Set Tomcat Admin and Manager Password
    Next Article Removing User from Secondary Group in Linux

    Related Posts

    How to Search Recently Modified Files in Linux

    2 Mins Read

    Bash Printf Command

    Updated:December 23, 20212 Mins Read

    Tee Command in Linux with Examples

    4 Mins Read

    How to Scan Open Ports with Nmap

    5 Mins Read

    Handling filenames with spaces in Linux

    3 Mins Read

    How To Compare Two Files in Linux

    Updated:August 23, 20215 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • What is CPU? – Definition, Types and Parts
    • What is the /etc/aliases file
    • What is the /etc/nsswitch.conf file in Linux
    • How to Install Ionic Framework on Ubuntu 22.04
    • What is the /etc/hosts file in Linux
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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