usermod says account doesn't exist but adduser says it does

25,862

To edit /etc/group directly use vigr

From man vigr

NAME
       vipw, vigr - edit the password, group, shadow-password or shadow-group file

SYNOPSIS
       vipw [options]

       vigr [options]

DESCRIPTION
       The vipw and vigr commands edits the files /etc/passwd and /etc/group, respectively. With the -s flag,
       they will edit the shadow versions of those files, /etc/shadow and /etc/gshadow, respectively. The
       programs will set the appropriate locks to prevent file corruption. When looking for an editor, the
       programs will first try the environment variable $VISUAL, then the environment variable $EDITOR, and
       finally the default editor, vi(1).

Hence, you can edit the /etc/group file with

sudo vigr

The format of group entries can be found in man. From man group:

NAME
       group - user group file

DESCRIPTION
       The  /etc/group file is a text file that defines the groups on the system.  There is one entry per line,
       with the following format:

           group_name:password:GID:user_list

       The fields are as follows:

       group_name  the name of the group.

       password    the (encrypted) group password.  If this field is empty, no password is needed.

       GID         the numeric group ID.

       user_list   a list of the usernames that are members of this group, separated by commas.

FILES
       /etc/group
Share:
25,862
A. Mashreghi
Author by

A. Mashreghi

Updated on September 18, 2022

Comments

  • A. Mashreghi
    A. Mashreghi over 1 year

    I run the command

    usermod -a -G dialout amashreghi
    

    but I get amashreghi doesn't exists, however, when I try to add the user using adduser

    adduser amashreghi
    

    It says that amashreghi already exists. What's going on?!

    • George Udosen
      George Udosen over 6 years
      Does amashreghi have a password?
    • A. Mashreghi
      A. Mashreghi over 6 years
      Yes, I am sudo user but not root. I have tried usermod with sudo as well though.
  • abu_bua
    abu_bua over 5 years
    Vim is not recommended to edit the group file: see unix.stackexchange.com/a/79177/262708
  • Nishant
    Nishant over 3 years
    Might want to do sudo grpconv if you are doing this with newgrp!