3

When I run the following command :

sudo usermod –c "Richard Tracy" dtracy 

I get the following error :

Usage: usermod [options] LOGIN

Options:
  -c, --comment COMMENT         new value of the GECOS field
  -d, --home HOME_DIR           new home directory for the user account
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP as new primary group
  -G, --groups GROUPS           new list of supplementary GROUPS
  -a, --append                  append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                him/her from other groups
  -h, --help                    display this help message and exit
  -l, --login NEW_LOGIN         new value of the login name
  -L, --lock                    lock the user account
  -m, --move-home               move contents of the home directory to the
                                new location (use only with -d)
  -o, --non-unique              allow using duplicate (non-unique) UID
  -p, --password PASSWORD       use encrypted password for the new password
  -R, --root CHROOT_DIR         directory to chroot into
  -s, --shell SHELL             new login shell for the user account
  -u, --uid UID                 new UID for the user account
  -U, --unlock                  unlock the user account
  -v, --add-subuids FIRST-LAST  add range of subordinate uids
  -V, --del-subuids FIRST-LAST  remove range of subordinate uids
  -w, --add-subgids FIRST-LAST  add range of subordinate gids
  -W, --del-subgids FIRST-LAST  remove range of subordinate gids
  -Z, --selinux-user SEUSER     new SELinux user mapping for the user account

It states that we can use -c option , then why is it not accepting it my command ? I also see that while creating user and having -c in the useradd command , still I receive the above message and operation fails.

To reproduce the above error , just run sudo useradd dtracy to create a user dtracy with defaults and then try to modify by above usermod command.

Number945
  • 167

1 Answers1

6

The command you ran contained –c, which is an en-dash followed by a c. Although option arguments like -c are often informally pronounced "dash c" they must actually begin with an ASCII hyphen character. This is the same as the ASCII minus character (one name for this character is "hyphen-minus") but different from other Unicode dash characters like the en dash and em dash.

Commands don't give any special meaning to those dash characters, so while a -c argument specifies the short option c, a –c argument does not specify any option at all. You were actually running usermod with three non-option arguments, which is not one of the syntaxes it accepts, so it printed its help message.

The reason people end up typing en dashes instead of hyphens in commands is--well, nobody does that. Instead, some websites convert hyphens to en dashes. So when a command is copied from a page of such a website and pasted into a terminal, it wrongly contains an en dash instead of a hyphen. This could also happen if one used a program like LibreOffice to store a list of commands (and didn't turn off autoformatting).

Similar problems that often arise in practice from such mangled text include the insertion of extra spaces near punctuation (very bad in rm -r commands!), replacement of straight quotes with curly quotes, and the disappearance of text between a < character and a matching > character.

The command you meant to run, sudo usermod -c "Richard Tracy" dtracy, works fine.

Eliah Kagan
  • 119,640