本文目录:
- 1、linux (centos6.5) 将用户加入用户组的问题
- 2、如何为Centos添加用户并赋予SSH权限
- 3、centos7查看有哪些用户权限
- 4、centos怎么修改root用户
linux (centos6.5) 将用户加入用户组的问题
操作步骤如下:
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 -Gn
4、现在,假设系统中另外存在一个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.
如何为Centos添加用户并赋予SSH权限
默认新建的用户就有SSH 的权限。
创建用户AA,然后设置AA的密码为1234567。 命令如下
useradd AA
passwd AA
重复两次1234567
就设置了AA账号的密码了。就能用AA这个账号登录CentOS了。
centos7查看有哪些用户权限
1、添加用户首先用adduser命令添加普通用户命令: adduser tommy //添加名tommy用户 passwd tommy //修改密码 Changing password for user tommy. New UNIX password: //输入新密码 Retype new UNIX password: //再输入新密码 passwd: all authentication tokens updated successfully. 2、赋予root权限:修改/etc/sudoers 文件找面行前面注释()掉 Allows people in group wheel to run all commands %wheel ALL=(ALL) ALL 修改用户使其属于root组(wheel)命令: usermod -g root tommy 修改完毕现用tommy帐号登录用命令 su – 即获root权限进行操作 二:修改/etc/sudoers 文件找面行root面添加行所示: Allow root to run any commands anywhere root ALL=(ALL) ALL tommy ALL=(ALL) ALL 修改完毕现用tommy帐号登录用命令 su – 即获root权限进行操作 三:修改/etc/passwd 文件找行用户ID修改 0 所示: tommy:x:500:500:tommy:/home/tommy:/bin/bash修改tommy:x:0:500:tommy:/home/tommy:/bin/bash 保存用tommy账户登录直接获取root帐号权限 友情提醒:虽三看简单便般推荐使用推荐使用二
centos怎么修改root用户
可以参考如下方法:
1、添加用户,首先用adduser命令添加一个普通用户,命令如下:
adduser tommy
//添加一个名为tommy的用户
passwd tommy //修改密码
Changing password for user tommy.
New UNIX password: //在这里输入新密码
Retype new UNIX password: //再次输入新密码
passwd: all authentication tokens updated successfully.
2、赋予root权限
方法一: 修改 /etc/sudoers 文件,找到下面一行,把前面的注释()去掉
Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
然后修改用户,使其属于root组(wheel),命令如下:
usermod -g root tommy
修改完毕,现在可以用tommy帐号登录,然后用命令 su – ,即可获得root权限进行操作。
本文来源:https://www.yuntue.com/post/99647.html | 云服务器网,转载请注明出处!

微信扫一扫打赏
支付宝扫一扫打赏