【问题标题】:Centos usermod -a don't add a user to a groupCentos usermod -a 不要将用户添加到组中
【发布时间】:2019-01-29 14:03:08
【问题描述】:

在我的项目中,我必须在我的 centos 服务器上创建一个组并添加两个用户;我愿意:

sudo groupadd editorial

然后我尝试将我的两个用户添加到这样的组中:

sudo usermod -a -G editorial nginx
sudo usermod -a -G editorial ec2-user

好的,没有错误,但是当我检查我的组时:

sudo groups editorial

在输出中我得到:

组:社论:没有这样的用户

为什么我不能将我的用户添加到组中?

提前致谢

【问题讨论】:

  • 这看起来更像是一般的 Linux 问题,而不是编程问题。
  • Stack Overflow 是一个编程和开发问题的网站。这个问题似乎离题了,因为它与编程或开发无关。请参阅帮助中心的What topics can I ask about here。也许Super UserUnix & Linux Stack Exchange 会是一个更好的提问地点。
  • 你可以试试命令sudo groups username。它会显示用户在哪个组中。

标签: linux centos user-mode-linux


【解决方案1】:

您的命令格式错误。你用commas而不是whitepsace分隔补充组,man usermod:

-G A list of supplementary groups which the user is also a member of. Each 
   group is separated from the next by a comma, with no intervening whitespace.

例子:

sudo usermod -a -G editorial,nginx nameofuser

而且这个问题有点接近,如果您正在编写脚本来执行此操作,那么在 StackOverflow 上可能没问题,但如果这只是一般的“我如何使用usermod”,那可能应该去Super UserUnix & Linux

【讨论】:

  • 如果我使用逗号我有一个错误,在本教程中使用空格:techrepublic.com/article/…
  • 这真的很奇怪。您需要提供给用户。我会编辑。笔记;使用我的真实用户名nameofuser
【解决方案2】:

愚蠢的问题.. 但是你在尝试 usermod 之前是否完成了“$sudo useradd nameofuser”?

【讨论】:

    猜你喜欢
    • 2021-03-26
    • 2016-10-13
    • 2013-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-23
    • 2021-11-29
    • 2011-11-19
    相关资源
    最近更新 更多