首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >useradd/usermod不接受-c

useradd/usermod不接受-c
EN

Ask Ubuntu用户
提问于 2019-09-04 06:34:05
回答 1查看 1.5K关注 0票数 3

当我运行以下命令时:

代码语言:javascript
复制
sudo usermod –c "Richard Tracy" dtracy 

我得到以下错误:

代码语言:javascript
复制
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

它说我们可以使用-c选项,那么为什么它不接受我的命令呢?我还看到,在创建用户并在-c命令中使用useradd时,仍然会收到上述消息,而操作将失败。

若要再现上述错误,只需运行sudo useradd dtracy以创建具有默认值的用户dtracy,然后尝试通过上面的usermod命令进行修改。

EN

回答 1

Ask Ubuntu用户

回答已采纳

发布于 2019-09-04 07:16:13

您运行的命令包含–c**,它是一个[en-破折号](https://en.wikipedia.org/wiki/Dash#En_dash),后面是** c**.**,尽管选项参数(如-c )通常非正式地发音为"dash c“,但它们实际上必须以ASCII连字符开头。这与ASCII减号字符相同(这个字符的一个名称是“连字符-减号”),但不同于其他Unicode破折号字符,如en破折号和em破折号。

命令不会给这些破折号赋予任何特殊的含义,所以当-c参数指定短选项c时,–c参数根本不指定任何选项。实际上,您运行的usermod有三个非选项参数,这不是它接受的语法之一,所以它打印了它的帮助消息。

人们在命令中输入en破折号而不是连字符的原因是--嗯,没人这样做。相反,一些网站将连字符转换为en破折号。因此,当命令从这样一个网站的页面复制并粘贴到终端时,它错误地包含了一个en破折号而不是一个连字符。如果使用像LibreOffice这样的程序来存储命令列表(并且没有关闭自动格式化),也可能发生这种情况。

在实践中,这些错误的文本常常会出现类似的问题,包括在标点符号附近插入额外的空格(在rm -r命令中非常糟糕!),用卷曲引号替换直引号,以及<字符和匹配的>字符之间的文本消失。

您想要运行的命令sudo usermod -c "Richard Tracy" dtracy运行良好。

票数 6
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1170710

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档