linux初始化腳本2

#!/bin/bash #==================================================== # Author: Mr.Song # Create Date: 2019-2-24 # Description: #==================================================== systemctl stop firewalld systemctl disable firewalld setenforce 0 sed -i 's/enforcing$/disabled/g' /etc/selinux/config #yum 配置 mkdir -p /etc/yum.repos.d/bak mv /etc/yum.repos.d/* /etc/yum.repos.d/bak/ cat > /etc/yum.repos.d/CentOS-Base.repo <<- EOF #CentOS-Base.repo # # The mirror system uses the connecting IP address of the client and the # update status of each mirror to pick mirrors that are updated to and # geographically close to the client. You should use this for CentOS updates # unless you are manually picking other mirrors. # # If the mirrorlist= does not work for you, as a fall back you can try the # remarked out baseurl= line instead. # # [base] name=CentOS-\$releasever - Base - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=os baseurl=http://mirrors.163.com/centos/\$releasever/os/\$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates] name=CentOS-\$releasever - Updates - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=updates baseurl=http://mirrors.163.com/centos/\$releasever/updates/\$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful [extras] name=CentOS-\$releasever - Extras - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=\$releasever&arch=\$basearch&repo=extras baseurl=http://mirrors.163.com/centos/\$releasever/extras/\$basearch/ gpgcheck=1 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages [centosplus] name=CentOS-\$releasever - Plus - 163.com baseurl=http://mirrors.163.com/centos/\$releasever/centosplus/\$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7 EOF yum install -y vim nano wget gcc chrony lrzsz bash-completion net-tools psmisc #yum install epel-release #yum install -y atop htop iftop ######################################################## #bash配置 cat >> ~/.bashrc <<- EOF alias cls='clear' #DOS風格的清空 alias h='history | tail' alias hg='history | grep' alias hl='history | less' #stty erase ^H #清除退格 (這個很有必要) export PS1="[\[\e[0;36m\]\u\[\e[m\]@\[\e[0;32m\]\h \[\e[0;35m\]\W\[\e[m\]]\\\\$" EOF ######################################################### #vim配置:行號、快捷鍵輸入文本、中文支持 cat >> ~/.vimrc <<-EOF set autoindent set nu syntax on set tabstop=4 set shiftwidth=4 set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 set termencoding=utf-8 set encoding=utf-8 function AddTitle() call setline(1,"#!/bin/bash") call append(1,"#====================================================") call append(2,"# Author: Mr.Song") call append(3,"# Create Date: " . strftime("%Y-%m-%d")) call append(4,"# Description: ") call append(5,"#====================================================") endf map <F4> :call AddTitle()<cr> EOF ######################################################### #openssh優化:禁用DNS查詢 sed -i -e '/#UseDNS/a\UseDNS no' /etc/ssh/sshd_config systemctl restart sshd sed -i 's#0.centos.pool.ntp.org#s2b.time.edu.cn#;s#1.centos.pool.ntp.org#ntp1.aliyun.com#;s#server 2.#\#server 2.#;s#server 3.#\#server 3.#' /etc/chrony.conf systemctl restart chronyd sed -i 's/ONBOOT=no/ONBOOT=yes/;s/BOOTPROTO=dhcp/BOOTPROTO=static/;/ONBOOT/a\IPADDR=192.168.10.22\nPREFIX=24\nDNS1=119.29.29.29' /etc/sysconfig/network-scripts/ifcfg-ens32 systemctl restart network
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章