首页 文章 精选 留言 我的

精选列表

搜索[脚本],共10014篇文章
优秀的个人博客,低调大师

Centos7 初始化脚本

#!bin/bash #authorchenkan #thisscriptforCentos7 #ChecktheOS echo"ChecktheOSisright?" yuminstallredhat-lsb-y#基于最小化安装的centos需安装lsb下面要用到 os=`uname-r|awk-F"."'{print$4}'` platform=`uname-i`#-i,显示硬件平台名称 if[$os!=el7||$platform!=x86-64];then echo-e"\e[1;31mthisscriptisonlyfor64bitel7operationsystem!\e[0m" exit-1 fi echo-e"\e[1;31mplatformisok!\e[0m" cat<<EOF +==============================+ |yoursystemisCentosx86_64| +==============================+ EOF echo-e"\e[1;31mChecktheOSFINSHED!\e[0m" sleep1 #version=`lsb_release-r-s|awk-F"."'{print$1}'`#此处可以判断版本号是不是7(利用-r-s进行筛选) :<<! version=`lsb_release-i-s|grepCentOS`#此处可显示系统名称,比上边好用一点 if[$version!="CentOS"];then echo-e"\e[1;31mthisscriptisonlyforCentOS\e[0m!" exit1 fi echo-e"\e[1;31msystemisright!\e[0m"#为了测试功能实现情况,用转义字符输出红色字符串 ! #Settheinstallationsourceofthesystemto163.com #先将CentOS-Base.repo进行备份(备份到CentOS-Base.repo.backup)中,以后需要可以很快的改回来 echo"Replacetheyumsource" mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.backup cd/etc/yum.repos.d/ wgethttp://mirrors.163.com/.help/CentOS7-Base-163.repo #阿里源 #wget-O/etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyun.com/repo/Centos-7.repo yummakecache echo-e"\e[1;31m2.Settheinstallationsourceofthesystemto163.comFINSHED!\e[0m" sleep1 #InstallEPELsourceandRPMforgesource #对于安装epel可以选择网易的源,我这边用的是阿里的源.而RPMforge,现在改名为RepoForge,用清华的源。 echo"InstallEPELsourceandRPMforgesource" rpm-ivhhttp://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm rpm--import/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 rpm--importhttps://mirrors.tuna.tsinghua.edu.cn/repoforge/RPM-GPG-KEY.dag.txt cat>>/etc/yum.repos.d/rpmforge.repo<<EOF#configurationfile [rpmforge] name=RHEL$releasever-RPMforge.net-dag baseurl=https://mirrors.tuna.tsinghua.edu.cn/repoforge/redhat/el7/en/$basearch/rpmforge mirrorlist=http://mirrorlist.repoforge.org/el7/mirrors-rpmforge enabled=1 protect=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag gpgcheck=1 [rpmforge-extras] name=RHEL$releasever-RPMforge.net-extras baseurl=https://mirrors.tuna.tsinghua.edu.cn/repoforge/redhat/el7/en/$basearch/extras mirrorlist=http://mirrorlist.repoforge.org/el7/mirrors-rpmforge-extras enabled=0 protect=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag gpgcheck=1 [rpmforge-testing] name=RHEL$releasever-RPMforge.net-testing baseurl=https://mirrors.tuna.tsinghua.edu.cn/repoforge/redhat/el7/en/$basearch/testing mirrorlist=http://mirrorlist.repoforge.org/el7/mirrors-rpmforge-testing enabled=0 protect=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag gpgcheck=1 EOF yumrepolistenabled#checktheenabled echo-e"\e[1;31mInstallEPELsourceandRPMforgesourceFINSHED!\e[0m" sleep1 #Updatesoftware echo"updatesoftware" yumcleanall#清除yum的缓存,yum安装的东西会储存在cache中,不清除很浪费。 yuminstallkernel-develkernel-headers&&echoexclude=kernel*>>/etc/yum.conf#安装kernel-devel和kernel-headers,并且在更新系统时,禁止更新kernel并将其重定向到yum.conf yum-yupdateglibc\*#更新C语言库 yum-yupdateyum\*rpm\*python\* echo-e"\e[1;31mUpdatesoftwareFINSHED!\e[0m" sleep1 #Settimetobesynchronized yum-yinstallntp#NetworkTimeProtocol echo"*10***/usr/sbin/ntpdates1a.time.edu.cn>/dev/null2>&1">>/var/spool/cron/root#将同步时间设置为北邮,2->stderr,1->stdout,0->stdin,意思就是执行每天上午10点进行时间同步,如果出现错误就输出。 servicecrondrestart#重启crond。crond是crontab的守护进程。 echo-e"\e[1;31mSettimetobesynchronizedFINSHED!\e[0m" sleep1 #这边提一下">"和">>"区别,">"定向输出到文件,如果文件不存在,就创建文件;如果文件存在,就将其清空再添加;">>"是将输出内容追加到目标文件中。如果文件不存在,就创建文件;如果文件存在,则将新的内容追加到那个文件的末尾,该文件中的原有内容不受影响 #increasethenumberoffiles echo"ulimit-SHn102400">>/etc/rc.local#ulimit-acat/etc/security/limits.conf可查看 cat>>/etc/security/limits.conf<<EOF *softnofile102400 *hardnofile102400 *softnproc102400 *hardnproc102400 EOF echo-e"\e[1;31mincreasethenumberoffilesFINSHED!\e[0m" sleep1 #closedSELinux echo"closeselinux" sed-i's/SELINUX=enforcing/SELINUX=disabled/'/etc/selinux/config#sed-i替换命令,前者替换后者。具体使用参考:http://man.linuxde.net/sed echo-e"\e[1;31mclosedSELinuxFINSHED!\e[0m" sleep1 #disabletheGSSAPIdisableDNSspeeduptheSSH sed-i's/^GSSAPIAuthenticationyes$/GSSAPIAuthenticationno/'/etc/ssh/sshd_config sed-i's/#UseDNSyes/UseDNSno/'/etc/ssh/sshd_config#禁止dns的反向解析 servicesshdrestart echo-e"\e[1;31mdisabletheGSSAPIdisableDNSspeeduptheSSHFINSHED!\e[0m" sleep1 #optimizekernelparameters echo"optimizekernelparameters" echo"#----optimizekernelparameters------">>/etc/sysctl.conf echo"net.core.netdev_max_backlog=32768">>/etc/sysctl.conf echo"net.core.rmem_default=8388608">>/etc/sysctl.conf echo"net.core.rmem_max=16777216">>/etc/sysctl.conf echo"net.core.somaxconn=32768">>/etc/sysctl.conf echo"net.core.wmem_default=8388608">>/etc/sysctl.conf echo"net.core.wmem_max=16777216">>/etc/sysctl.conf echo"net.ipv4.ip_local_port_range=500065000">>/etc/sysctl.conf echo"net.ipv4.tcp_fin_timeout=30">>/etc/sysctl.conf echo"net.ipv4.tcp_keepalive_time=300">>/etc/sysctl.conf echo"net.ipv4.tcp_max_orphans=3276800">>/etc/sysctl.conf echo"net.ipv4.tcp_max_syn_backlog=65536">>/etc/sysctl.conf echo"net.ipv4.tcp_max_tw_buckets=5000">>/etc/sysctl.conf echo"net.ipv4.tcp_mem=94500000915000000927000000">>/etc/sysctl.conf echo"net.ipv4.tcp_syn_retries=2">>/etc/sysctl.conf echo"net.ipv4.tcp_synack_retries=2">>/etc/sysctl.conf echo"net.ipv4.tcp_syncookies=1">>/etc/sysctl.conf echo"net.ipv4.tcp_timestamps=0">>/etc/sysctl.conf echo"net.ipv4.tcp_tw_recycle=1">>/etc/sysctl.conf echo"net.ipv4.tcp_tw_reuse=1">>/etc/sysctl.conf /sbin/sysctl-p echo-e"\e[1;31moptimizekernelparametersFINSHED!\e[0m" sleep1 #adjustthekeyofthedeletedcharactertobackspace echo"adjustthekeyofthedeletedcharactertobackspace" echo'sttyerase^H'>>/etc/profile#默认^? echo'syntaxon'>>/root/.vimrc echo-e"\e[1;31madjustthekeyofthedeletedcharactertobackspaceFINSHED!\e[0m" sleep1 #canceldatabase echo"canceldatabase" if[[-e/etc/cron.daily.bak ]];then rm-rf/etc/cron.daily.bak fi mkdir/etc/cron.daily.bak mv/etc/cron.daily/mlocate/etc/cron.daily.bak echo-e"\e[1;31mcanceldatabaseFINSHED!\e[0m" sleep1 #shutdownunusedservices echo"shutdownunusedservices" systemctlstopfirewalld systemctldisablecups systemctldisablefirewalld systemctldisableauditd.service systemctldisableirqbalance.service systemctldisablelvm2-monitor.service echo-e"\e[1;31mshutdownunusedservicesFINSHED!\e[0m" sleep1 #disabletheipv6 echo"disabletheipv6" cat>>/etc/modprobe.d/ipv6.conf<<EOFI aliasnet-pf-10off optionsipv6disable=1 EOFI echo"NETWORKING_IPV6=off">>/etc/sysconfig/network echo-e"\e[1;31mdisabletheipv6FINSHED!\e[0m" sleep1

优秀的个人博客,低调大师

Python difflib字符串比较脚本

!/usr/bin/python import difflib text1 = """text1: #定义字符串1 This module provides classes and functions for comparing sequences. including HTML and context and unified diffs. difflib document v7.4 add string """ text1_lines = text1.splitlines() #以行进行分隔,以便进行对比 text2 = """text2: #定义字符串2 This module provides classes and functions for Comparing sequences. including HTML and context and unified diffs. difflib document v7.5""" text2_lines = text2.splitlines() d = difflib.Differ() #创建Differ()对象 diff = d.compare(text1_lines, text2_lines) # 采用compare方法对字符串进行比较 print '\n'.join(list(diff))

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册