CentOS7系列--1.3CentOS7用户管理
CentOS7用户管理
1. 添加用户
[root@centos7 ~]# useradd jack
[root@centos7 ~]# passwd jack
Changing password for user jack.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@centos7 ~]# exit
2. 切换用户
以新添加的用户登录,然后切换到root账号
login as: jack
jack@192.168.1.101's password:
[jack@centos7 ~]$ su -
Password:
Last login: Fri Oct 27 06:14:50 CST 2017 from 192.168.1.100 on pts/0
[root@centos7 ~]#
3. 将用户作为仅有的可切换到Root的账号
[root@centos7 ~]# usermod -G wheel jack
[root@centos7 ~]# vi /etc/pam.d/su
#%PAM-1.0
auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
auth required pam_wheel.so use_uid
auth substack system-auth
auth include postlogin
account sufficient pam_succeed_if.so uid = 0 use_uid quiet
account include system-auth
password include system-auth
session include system-auth
session include postlogin
session optional pam_xauth.so
4. 将发向 root的邮件转到新创建的用户
[root@centos7 ~]# vi /etc/aliases
gdm: root
mailnull: root
postgres: root
sshd: root
smmsp: root
postfix: root
netdump: root
ldap: root
squid: root
ntp: root
mysql: root
desktop: root
rpcuser: root
rpc: root
nfsnobody: root
ingres: root
system: root
toor: root
manager: root
dumper: root
abuse: root
newsadm: news
newsadmin: news
usenet: news
ftpadm: ftp
ftpadmin: ftp
ftp-adm: ftp
ftp-admin: ftp
www: webmaster
webmaster: root
noc: root
security: root
hostmaster: root
info: postmaster
marketing: postmaster
sales: postmaster
support: postmaster
# trap decode to catch security attacks
decode: root
# Person who should get root's mail
#root: marc
root: jack