sample login: root ← 用root用户来登陆系统,输入用户名root Password: ← 在这里输入安装时设置的root密码,输入时密码不会被显示 [root@sample ~]# ← root用户登陆成功,提示符为“#”。若通常用户登陆成功后,提示符为“$” [root@sample ~]# exit ← 退出系统
[root@sample ~]# useradd centospub ← 创建用户名为 centospub 的通常用户 [root@sample ~]# passwd centospub ← 为用户 centospub 设置密码 Changing password for user centospub. New UNIX password: ← 输入密码(密码不会被显示) Retype new UNIX password: ← 再次输入密码确认两次密码一致 passwd: all authentication tokens updated successfully. ← 密码设置成功 [root@sample ~]# userdel -r centospub ← 删除用户名为 centospub 的通常用户
由于root用户对系统具备全权的操做权限,为了不一些失误的操做,建议在通常状况下,以通常用户登陆系统,必要的时候须要root操做权限时,再经过“su -”命令来登陆为root用户进行操做。centos
[centospub@sample ~]$ ← 提示符为“$”,说明当前状态为通常用户centospub登陆在系统中 [centospub@sample ~]$ su – ← 输入登陆为root用户的命令 Password: ← 输入root密码(密码不会被显示),回车 [root@sample ~]# ← 成功登陆为root用户,提示符变为“#” [root@sample ~]# exit ← 回到通常用户的登陆状态 [centospub@sample ~]$ ← 提示符变为“$”,回到了通常用户centospub登陆系统的状态
在 通常状况下,通常用户经过执行“su -”命令、输入正确的root密码,能够登陆为root用户来对系统进行管理员级别的配置。可是,为了更进一步增强系统的安全性,有必要创建一个管理员的 组,只容许这个组的用户来执行“su -”命令登陆为root用户,而让其余组的用户即便执行“su -”、输入了正确的root密码,也没法登陆为root用户。在UNIX下,这个组的名称一般为“wheel”。安全
[root@sample ~]# usermod -G wheel centospub ← 将通常用户 centospub 加在管理员组wheel组中 [root@sample ~]# vi /etc/pam.d/su ← 打开这个配置文件 #auth required /lib/security/$ISA/pam_wheel.so use_uid ← 找到此行,去掉行首的“#” ↓ auth required /lib/security/$ISA/pam_wheel.so use_uid ← 变为此状态(大约在第6行的位置) [root@sample ~]# echo “SU_WHEEL_ONLY yes” >> /etc/login.defs ← 添加语句到行末
以上操做完成后,能够再创建一个新用户,而后用这个新建的用户测试会发现,没有加入到wheel组的用户,执行“su -”命令,即便输入了正确的root密码,也没法登陆为root用户测试