新增用户、修改密码、修改用户权限
新增用户
[root@KVM-01 ~]# useradd test02
[root@KVM-01 ~]# passwd test02
Changing password for user test02.
New password:
BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.
后面更改用户密码可以再次使用passwd+用户名修改用户密码
还有一种骚操作
root 模式下
[root@KVM-01 ~]# echo test02:123456|chpasswd
给用户设置权限
正常情况下,非root用户只能对其home目录下有执行权限
[test02@KVM-01 home]$ ll
total 0
drwx------. 2 test test 83 Aug 25 00:25 test
drwx------. 2 test02 test02 102 Aug 25 09:10 test02
[test02@KVM-01 home]$
[test02@KVM-01 home]$ cd /root/
-bash: cd: /root/: Permission denied
[test02@KVM-01 home]$ umask
0002
[test02@KVM-01 home]$
为了让test02有权限,可以把test02加入到root所属组中解决,或者直接为test02设置特权
sudo的权限保存在sudoers中
[root@KVM-01 ~]# whereis sudoers
sudoers: /etc/sudoers /etc/sudoers.d /usr/share/man/man5/sudoers.5.gz
[root@KVM-01 ~]# ll /etc/sudoers
-r--r-----. 1 root root 4328 Nov 28 2019 /etc/sudoers #没有可读权限,需要增加读权限
[root@KVM-01 ~]# chmod +w /etc/sudoers
[root@KVM-01 ~]# ll /etc/sudoers
-rw-r-----. 1 root root 4328 Nov 28 2019 /etc/sudoers
[root@KVM-01 ~]# vi /etc/sudoers
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
test02 ALL=(ALL) ALL
## Allows members of the 'sys' group to run networking, software,
小彩蛋:
开机启用基础命令
[root@KVM-01 ~]# chkconfig libvirtd on
Note: Forwarding request to 'systemctl enable libvirtd.service'.

浙公网安备 33010602011771号