日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux系统优化脚本

發布時間:2024/9/30 linux 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux系统优化脚本 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
-------------------------------------------------------------------- 注:如果你對python感興趣,我這有個學習Python基地,里面有很多學習資料,感興趣的+Q群:895817687 -------------------------------------------------------------------- --------------------- #!/bin/bash ############################################################################## # File Name : Linux system config # description : This script is used to set linux system # Author : simon # Mail : 24731701@qq.com ############################################################################## . /etc/init.d/functions IP=`/sbin/ifconfig|awk -F '[ :]+' 'NR==2{print $4}'`# Defined result functionfunction Msg(){if [ $? -eq 0 ];thenaction "$1" /bin/trueelseaction "$1" /bin/falsefi}# Defined Close selinux Functions function selinux(){[ if "/etc/selinux/config" ] && {sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/configsetenforce 0Msg "Close selinux" } }# Defined add Ordinary users Functionsfunction AddUser(){id simon &>/dev/nullif [ $? -ne 0 ];thenuseradd simon &>/dev/nullecho "123456"|passwd --stdin simon &>/dev/null &&\sed -ir '98a simon ALL=(ALL) NOPASSWD:ALL' /etc/sudoers &&\visudo -c &>/dev/nullMsg "AddUser simon"elseecho "simon user is exist."fi }# Defined Hide the system version number Functionsfunction HideVersion(){[ -f "/etc/issue" ] && >/etc/issue[ -f "/etc/issue.net"] && > /etc/issue.netMsg "Hide sys info." }# Defined sshd config Functionsfunction sshd(){sshd_file=/etc/ssh/sshd_configif [ `grep "52113" $sshd_file|wc -l` -eq 0 ];thensed -ir "13 iPort 52113\nPermitRootLogin no\nPermitEmptyPasswords no\nUseDNS no\nGSSAPIAuthentication no" $sshd_filesed -i 's@#ListenAddress 0.0.0.0@ListenAddress '${IP}':52113@g' $sshd_file/etc/init.d/sshd restart > /dev/null 2>&1Msg "sshd config"fi }# Defined OPEN FILES Functions function openfiles(){if [ `grep "nofile 65535" /etc/security/limits.conf|wc -l` -eq 0 ];thenecho '* - nofile 65535' >> /etc/security/limits.confulimit -SHn 65535Msg "open files"fi }function hosts(){if [ ! -f /server/scripts/hosts ];thenecho "/server/scripts/hosts is not exist,please solve this question"sleep 300exit 1fi/bin/cp /server/scripts/hosts /etc/hosts }# Defined System Startup Services Functionsfunction boot(){export LANG=enfor simon in `chkconfig --list|grep "3:on"|awk '{print $1}'|egrep -v "crond|network|rsyslog|sshd|sysstat"`dochkconfig $simon offdoneMsg "BOOT config" }# Deined Time Synchronization Functions function Time(){grep "time.nist.gov" /var/spool/cron/root > /dev/null 2>&1if [ $? -ne 0 ];thenecho "#time sync by simon at $(date +%F)" >>/var/spool/cron/rootecho "*/5 * * * * /usr/sbin/ntpdate time.nist.gov &>/dev/null" >>/var/spool/cron/rootfiMsg "Time Synchronization"} # Defined Kernel parameters Functions function Kernel(){/bin/cp /etc/sysctl.conf /etc/sysctl.conf.$RANDOM/bin/cp /server/scripts/sysctl.conf /etc/Msg "kernel"}function iptables(){/etc/init.d/iptables stop/etc/init.d/iptables stopMsg "iptables"}function hostname(){ip=`/sbin/ifconfig eth1|awk -F "[: ]+" 'NR==2 {print $4}'`name=`grep -w "$ip" /etc/hosts |awk '{print $2}'`sed -i 's/HOSTNAME=*/HOSTNAME='"$name"'/g' /etc/sysconfig/network/bin/hostname $nameMsg "hostname"}# Defined main Functions function main(){AddUserHideVersionsshdopenfileshostsbootTimeKerneliptableshostname }main

總結

以上是生活随笔為你收集整理的Linux系统优化脚本的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。