| [root@bogon ~]# visudo 可以看见缺省只有一条配置: root ALL=(ALL) ALL 那么你就在下边再加一条配置: support ALL=(ALL) ALL 这样,普通用户support就能够执行root权限的所有命令 以support用户登录之后,执行: sudo su - 然后输入support用户自己的密码,就可以切换成root用户了 让普通用户support只能在某几台服务器上,执行root能执行的某些命令 首先需要配置一些Alias,这样在下面配置权限时,会方便一些,不用写大段大段的配置。Alias主要分成4种 Host_Alias Cmnd_Alias User_Alias Runas_Alias 1) 配置Host_Alias:就是主机的列表 Host_Alias HOST_FLAG = hostname1, hostname2, hostname3 2) 配置Cmnd_Alias:就是允许执行的命令的列表 Cmnd_Alias COMMAND_FLAG = command1, command2, command3 3) 配置User_Alias:就是具有sudo权限的用户的列表 User_Alias USER_FLAG = user1, user2, user3 4) 配置Runas_Alias:就是用户以什么身份执行(例如root,或者Oracle)的列表 Runas_Alias RUNAS_FLAG = operator1, operator2, operator3 5) 配置权限 配置权限的格式如下: USER_FLAG HOST_FLAG=(RUNAS_FLAG) COMMAND_FLAG 如果不需要密码验证的话,则按照这样的格式来配置 USER_FLAG HOST_FLAG=(RUNAS_FLAG) NOPASSWD: COMMAND_FLAG 配置示例: ################################################## # 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 Host_Alias EPG = 192.168.1.1, 192.168.1.2 允许这两个ip登入的主机执行root命令 # User alias specification # Cmnd alias specification Cmnd_Alias SQUID = /opt/vtbin/squid_refresh, /sbin/service, /bin/rm 允许执行的root命令 # Defaults specification # User privilege specification root ALL=(ALL) ALL support EPG=(ALL) NOPASSWD: SQUID support用户也可以执行root的命令了 # 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 |
------------------------------------------
4 配置服务
chkconfig --list 查看系统服务
chkconfig netfs off 停止netfs服务
停止打印服务
如果不准备提供打印服务,停止默认被设置为自动启动的打印服务。
| [root@bogon ~]# /etc/rc.d/init.d/cups stop ← 停止打印服务 Stopping cups: [ OK ] ← 停止服务成功,出现“OK” [root@bogon ~]# chkconfig cups off ← 禁止打印服务自动启动 [root@bogon ~]# chkconfig --list cups ← 确认打印服务自启动设置状态 cups 0:off 1:off 2:off 3:off 4:off 5:off 6:off ← 0-6都为off的状态就OK(当前打印服务自启动被禁止中) [10] 停止ipv6 在CentOS默认的状态下,ipv6是被启用的状态。因为我���不使用ipv6,所以,停止ipv6,以最大限度保证安全和快速。 首先再次确认一下ipv6功能是不是被启动的状态。 [root@sample ~]# ifconfig -a ← 列出全部网络接口信息 eth0 Link encap:Ethernet HWaddr 00:0C:29:B6:16:A3 inet addr:192.168.0.13 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:feb6:16a3/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:84 errors:0 dropped:0 overruns:0 frame:0 TX packets:93 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:10288 (10.0 KiB) TX bytes:9337 (9.1 KiB) Interrupt:185 Base address:0x1400 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:12 errors:0 dropped:0 overruns:0 frame:0 TX packets:12 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:952 (952.0 b) TX bytes:952 (952.0 b) sit0 Link encap:IPv6-in-IPv4 ← 确认ipv6是被启动的状态 NOARP MTU:1480 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) 然后修改相应配置文件,停止ipv6。 [root@sample ~]# vi /etc/modprobe.conf ← 修改相应配置文件,添加如下行到文尾: alias net-pf-10 off alias ipv6 off [root@bogon ~]# shutdown -r now ← 重新启动系统,使设置生效 最后确认ipv6的功能已经被关闭。 [root@sample ~]# ifconfig -a ← 列出全部网络接口信息 eth0 Link encap:Ethernet HWaddr 00:0C:29:B6:16:A3 inet addr:192.168.0.13 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:feb6:16a3/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:84 errors:0 dropped:0 overruns:0 frame:0 TX packets:93 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:10288 (10.0 KiB) TX bytes:9337 (9.1 KiB) Interrupt:185 Base address:0x1400 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:12 errors:0 dropped:0 overruns:0 frame:0 TX packets:12 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:952 (952.0 b) TX bytes:952 (952.0 b) (确认ipv6的相关信息没有被列出,说明ipv6功能已被关闭。) |
CentOS Server首次安装后的关闭不需要的服务
| service smartd stop chkconfig smartd off 服务说明: smartd检查硬盘故障,虚拟的硬盘是无法用这个服务来检查,只对实体的装置才有用。 1.停止服务 service apmd stop service autofs stop service bluetooth stop service cups stop service ip6table stop service iptable stop #service isdn stop service hidd stop service pcscd stop service pcmcia off #service sendmail stop service yum-updatesd stop 2.设定不启动 chkconfig apmd off chkconfig autofs off chkconfig bluetooth off chkconfig cups off chkconfig ip6table off chkconfig iptable off #chkconfig idsn off chkconfig hidd off chkconfig pcscd off service pcmcia off #chkconfig sendmail off chkconfig yum-updatesd off 服务说明: apmd电源管理 没有UPS或是没有电池的电脑这是没用的 autofs自动挂载服务 通常server所需要挂载都是固定的,除非是特殊的目的,否则用处不大。 bluetooth蓝芽 Server应该是不太需要用蓝芽 cups列印 如果列印需求的机器才需要打开 iptable6,iptable 建议交由防火墙来管理连线, Server专注服务即可(这个工具自己需要) isdn 如果有需要建立ISDN的环境,才需要使用 hidd 一些蓝芽的输入装置,如键盘滑鼠等。 Server应该不太会用到这些装置,有点太高档的感觉! pcscd 给smart card用的,目前手上没有这种机器,所以都是关掉的。 pcmcia 给pcmcia用的,目前Server很少用到pcmcia,关掉。 yum-updatesd yum自动升级程式, CentOS 5预设会安装,不过有时候自动安装会造成一些不必要的困扰,目前大部分的人建议是不要启用,尤其是已经上线的主机。 |
