用户管理
创建用户并赋权
创建新用户
shell
[root@VM_0_6_centos ~]# adduser northmeter
[root@VM_0_6_centos ~]# passwd northmeter
Changing password for user northmeter.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
# 授权
[root@VM_0_6_centos ~]# ls -l /etc/sudoers
-r--r-----. 1 root root 3938 Jun 7 2017 /etc/sudoers
[root@VM_0_6_centos ~]# chmod -v u+w /etc/sudoers
mode of ‘/etc/sudoers’ changed from 0440 (r--r-----) to 0640 (rw-r-----)
[root@VM_0_6_centos ~]# vi /etc/sudoers
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
northmeter ALL=(ALL) ALL
[root@VM_0_6_centos ~]# chmod -v u-w /etc/sudoers
mode of ‘/etc/sudoers’ changed from 0640 (rw-r-----) to 0440 (r--r-----)登录
shell
[root@200 ~]# ssh northmeter@193.112.249.36
northmeter@193.112.249.36's password:
Last login: Tue Jun 5 12:37:45 2018 from 218.17.157.121测试
shell
[root@VM_0_6_centos ~]# su northmeter
[northmeter@VM_0_6_centos root]$ sudo cat /etc/passwd
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for northmeter:
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
systemd-network:x:192:192:systemd Network Management:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
polkitd:x:999:997:User for polkitd:/:/sbin/nologin
libstoragemgmt:x:998:996:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
abrt:x:173:173::/etc/abrt:/sbin/nologin
rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
chrony:x:997:995::/var/lib/chrony:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
syslog:x:996:994::/home/syslog:/bin/false
centos:x:1000:1000:Cloud User:/home/centos:/bin/bash
northmeter:x:1001:1001::/home/northmeter:/bin/bash