[英]Centos usermod -a don't add a user to a group
In my project i have to create a group on my centos server and add two users;在我的项目中,我必须在我的 centos 服务器上创建一个组并添加两个用户; i do:我愿意:
sudo groupadd editorial
then i try to add my two users to group like this:然后我尝试将我的两个用户添加到这样的组中:
sudo usermod -a -G editorial nginx
sudo usermod -a -G editorial ec2-user
ok, no errors, but when i check my group:好的,没有错误,但是当我检查我的组时:
sudo groups editorial
in output i get:在输出中我得到:
groups: editorial: no such user组:社论:没有这样的用户
why i cannot add my user to group?为什么我不能将我的用户添加到组?
Thanks in advance提前致谢
愚蠢的问题..但是在尝试 usermod 之前你做过“$sudo useradd nameofuser”吗?
Your form of the command is wrong.你的命令形式是错误的。 You separate the supplemental groups with commas
not whitepsace
, man usermod:您用commas
而不是whitepsace
commas
补充组, 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.
Example:例子:
sudo usermod -a -G editorial,nginx nameofuser
And this questions is somewhat a close call, if you are writing a script to do this, then that is probably OK on StackOverflow, but if this is just a general "How do I use usermod
", that should probably go to Super User or Unix & Linux这个问题有点接近,如果你正在编写一个脚本来做到这一点,那么在 StackOverflow 上可能没问题,但如果这只是一个一般的“我如何使用usermod
”,那应该去超级用户或Unix 和 Linux
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.