2 Responses to Change Linux User login and Group

  1. I guess the “groupmod -n ” will require that you are logged in with the user which you are changing; however below you say “make sure you are logged in as a different user”. Aren’t you going to change the group of the “different user” that way?

    As far as I know the changing of group and getting rid of others can be done with the following two commands one after another:

    # usermod -g
    # usermod -G

    Alternatively if you want to keep all existing groups as secondary you can use the “-a” flag and directly issue only this command:

    # usermod -a -G

    This will preserve all existing groups and change the primarily group only.

  2. I guess the “groupmod -n ” will require that you are logged in with the user which you are changing; however below you say “make sure you are logged in as a different user”. Aren’t you going to change the group of the “different user” that way?

    As far as I know the changing of group and getting rid of others can be done with the following two commands one after another:

    # usermod -g <newgroup> <user>
    # usermod -G <newgroup> <user>

    Alternatively if you want to keep all existing groups as secondary you can use the “-a” flag and directly issue only this command:

    # usermod -a -G <newgroup> <user>

    This will preserve all existing groups and change the primarily group only.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>