1. 限制某些用户使用su命令
2. 限制只能wheel组能使用sudo命令
3. 演示让普通用户使用root命令(自己玩的使用)
4. 配置服务 关闭一些你不需要的服务
5. 更新yum在线库 寻找最快的软件仓库
6. 关闭SELINUX
7. 对linux的文件权限补充(对于服务器配置来说很重要的知识点)
1 控制cent用户能使用su 命令 登入root用户
[root@bogon ~]# useradd cent 添加用户[root@bogon ~]# passwd cent 设置密码一样
[root@bogon ~]# vi /etc/group 编辑cent为wheel组
wheel:x:10:root,cent
[root@bogon ~]# vi /etc/pam.d/su 编辑只能wheel组的用户能使用su命令
auth required pam_wheel.so use_uid
[root@bogon ~]# vi /etc/aliases
root:cen
------------------------------------------
2 控制只能wheel组能使用sudo命令
[root@bogon ~]# vi /etc/sudoers
root ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
%wheel ALL=(ALL) ALL 添加wheel组能使用sudo命令
# Same thing without a password
%wheel ALL=(ALL) NOPASSWD: ALL
下面自定义一些权限控制 比如控制所有用户除了root都不能执行 关机 重启命令
Cmnd_Alias SHUTDOWN = /sbin/halt, /sbin/shutdown, \
/sbin/poweroff, /sbin/reboot, /sbin/init
# add ( commands in aliase 'SHUTDOWN' are not allowed )
cent ALL=(ALL) ALL,!SHUTDOWN 不能执行关机命令
sudo是linux下常用的允许普通用户使用超级用户权限的工具。
它的主要配置文件是sudoers,linux下通常在/etc目录下,如果是solaris,sudo都提供了一个编辑该文件的命令:visudo来对该文件进行修改。强烈推荐使用该命令修改sudoers,因为它会帮你校验文件配置是否正确,如果不正确,在保存退出时就会提示你哪段配置出错的。
言归正传,下面介绍如何配置sudoers
首先写sudoers的缺省配置:
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#
# Host alias specification
# User alias specification
# Cmnd alias specification
# Defaults specification
# User privilege specification
root ALL=(ALL) ALL
# Uncomment to allow people in group wheel to run all commands
# %wheel ALL=(ALL) ALL
# Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL
# Samples
# %users ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users localhost=/sbin/shutdown -h now
##################################################
此文章由 http://www.ositren.com 收集整理 ,地址为: http://www.ositren.com/htmls/66192.html