Centos系统怎么添加用户和组

Centos系统怎么添加用户和组,第1张

*** 作步骤如下:1、当使用一种普通的方式创建用户时,比如:Shell代码#useradd testuser1所创建的用户testuser1,所在的group,以及supplementary group中均仅包含一个名称。想将用户testuser1加入一个其它已存在的组,则需对用户testuser1的supplementary group进行设置。2、首先查看下testuser1的当前情况:Shell代码#id testuser1这会得到类似下面的输出:Shell代码uid=502(testuser1) gid=502(testuser1) groups=502(testuser1)3、也可以使用下面的命令:Shell代码#groups testuser1这会得到类似下面的输出:Shell代码testuser1 : testuser1其实,命令groups的作用等同于:Shell代码id -Gn4、现在,假设系统中另外存在一个group,名称为testgroup1,使用下面的命令使用户testuser1的supplementary group包括这个group:Shell代码#usermod -a -G testgroup1现在再次查看下testuser1的情况,就会得到类似下面的输出:Shell代码uid=502(testuser1) gid=502(testuser1)groups=502(testuser1),501(testgroup1)当然这里的group id为501同样是个演示而已.需要注意,对于上面使用的命令usermod,需要加入选项'-a',这表示是追加 *** 作.如果仅有选项'-G',则需要在其后面所跟的参数中列出所有的supplementary group.

第一步 用户授权

创建账户必须授权,不然,个人用户的权限只可以在本home下有权限,其他的必须有授权,一般需要root的权限,sudo的命令授权一般在sudoers里面,找到sudoer文件位置,看下文件的权限

[root@iZ2ze503xw2q1fftv5rhboZ ~]# whereis sudoers

sudoers: /etc/sudoers /etc/sudoers.d /usr/libexec/sudoers.so /usr/share/man/man5/sudoers.5.gz

第二步:编辑sudoers文件并强制保存修改权限

[root@iZ2ze503xw2q1fftv5rhboZ ~]# vim /etc/sudoers

[root@iZ2ze503xw2q1fftv5rhboZ ~]# chmod -v u+w /etc/sudoers  //收回权限mode of `/etc/sudoers' changed to 0640 (rw-r-----)


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11963122.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存