shell脚本快速初始化Linux系统,一键操作,快速上手

#!/bin/bash

#writer by 刘国华教育

#关闭selinux
sed -i '/SELINUX/{s/permissive/disabled}' /etc/selinux/config

#历史命令增加操作时间
if ! grep HISTTIMEFORMAT /etc/bashrc
then	
  echo 'export HISTTIMEFORMAT="%F %T 'whoami' "' >> /etc/bashrc
 fi

#设置SSH超时时间
if ! grep "TMOUT" /etc/profile &>/dev/null
then	
  echo "export TMOUT=900" >> /etc/profile
fi

#设置最大打开文件数
if ! grep "* soft nofile 65535" /etc/security/limits.conf &>/dev/null
then	
cat >> /etc/security/limits.conf << EOF	
* soft nofile 65535	
* hard nofile 65535
EOF
fi

# 禁止root远程登录
sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config

 

声明:欢迎大家光临本站,学习IT运维技术,转载本站内容,请注明内容出处”来源刘国华教育“。如若本站内容侵犯了原著者的合法权益,请联系我们进行处理。