重新载入SSH配置 /etc/init.d/sshd reload 查看端口里面是否有刚才修改过的端口号52113
netstat -lnt
或者反查端口是那个进程
lsof -i tcp:52113
centos6.5最小化安装没有lsof工具需要 yum install lsof
9、锁定关键文件系统(禁止非授权用户获得权限)
chattr +i /etc/passwd chattr +i /etc/inittab chattr +i /etc/group chattr +i /etc/shadow chattr +i /etc/gshadow
10、精简开机自启动服务
注意: 刚装完操作系统一般可以只保留crond,network,syslog,sshd这四个服务。 后期根据业务需求制定自启服务 #(Centos6.x为rsyslog Cetnos5.x为syslog) 如果是中文的话。可能会需要LANG=en 或者替换 3:on 成 3:启用
#关闭全部服务
for sun in `chkconfig --list|grep 3:on|awk '{print $1}'`;do chkconfig --level 3 $sun off;done
#或者
for sun in `chkconfig --list|grep 3:启用|awk '{print $1}'`;do chkconfig --level 3 $sun off;done
#开启需要的服务
for sun in crond rsyslog sshd network;do chkconfig --level 3 $sun on;done
#或者需要使用防火墙的话可以开启iptables和ip6tables
for sun in crond rsyslog sshd network iptables ip6tables;do chkconfig --level 3 $sun on;done
查询下开启的服务 chkconfig –list | grep 3:on 或者 chkconfig –list|grep 3:启用
[bingoku@c65mini ~]$ chkconfig --list|grep 3:启用 crond 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭 ip6tables 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭 iptables 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭 network 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭 rsyslog 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭 sshd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
11、调整文件描述符大小
#查看文件描述符大小
ulimit -n
第一种:#这里参考的是阿里云主机默认设置。
vi /etc/security/limits.conf * soft nofile 65535 * hard nofile 65535 * soft nproc 65535 * hard nproc 65535 * soft nofile 65535 * hard nofile 65535
第二种:echo '* - nofile 65535' >> /etc/security/limits.conf
第三种:把ulimit -SHn 65535命令加入到/etc/rc.local,然后每次重启生效 追加命令到rc.local配置文件里面
cat >>/etc/rc.local<<EOF #open files ulimit -HSn 65535 #stack size ulimit -s 65535 EOF
第四种:如果不修改limits配置文件,直接立即生效,但重启后又恢复之前的默认。 ulimit -SHn 65535
12、设置系统字符集
第一种:vi /etc/sysconfig/i18n
如果想用中文提示:LANG=”zh_CN.UTF-8″ 如果想用英文提示:LANG=”en_US.UTF-8″ 如果临时切换也可以 LANG=zh_CN.UTF-8
第二种:使用sed快速替换








