系统初始化脚本
CentOS-7.4.1708
# CentOS-7.4.1708
yum clean all && yum makecache
sed -i "s/^#UseDNS.*/UseDNS no/g" /etc/ssh/sshd_config
sed -i "s/SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config
systemctl stop firewalld && systemctl disable firewalld && rpm -e --nodeps firewalld
yum -y install iptables-services
systemctl start iptables && iptables -F && service iptables save
yum -y install lrzsz net-tools bash-completion vim tree kernel-tools kernel-devel \
wget dos2unix ntpdate unzip psmisc tcpdump mailx patch
cat >> ~/.vimrc <<EOF
set ts=4
EOF
curl -sSo /etc/pki/ca-trust/source/anchors/private-ca-root.pem \
https://gitee.com/outsrkem/my_private_ca_pem/raw/main/pki/ca.pem && /bin/update-ca-trust
禁用ipv6
vi /etc/default/grub 找到GRUB_CMDLINE_LINUX这一行,在双引号内加入如下内容,注意与其他项目之间使用空格隔开: GRUB_CMDLINE_LINUX="ipv6.disable=1" # 命令添加 cp /etc/default/grub{,-`date +%Y%m%d%H%M%S`} DISALIEIPV6='GRUB_CMDLINE_LINUX="ipv6.disable=1 ' echo "$DISALIEIPV6`cat /etc/default/grub |grep GRUB_CMDLINE_LINUX|awk -F '"' '{print $2}'`\"" GRUB_CMDLINE_LINUX="$DISALIEIPV6`cat /etc/default/grub |grep GRUB_CMDLINE_LINUX|awk -F '"' '{print $2}'`\"" sed "s/GRUB_CMDLINE_LINUX=.*/${GRUB_CMDLINE_LINUX}/g" /etc/default/grub # 重新生成grub.cfg grub2-mkconfig -o /boot/grub2/grub.cfg grep ipv6 /boot/grub2/grub.cfg reboot


命令提示符 :
export PS1='\[\e[1;32m\][\u@\h \W]\$ \[\e[0m\]'
\[[a-zA-Z0-9]+@[a-zA-Z0-9-_]+\s(~|[a-zA-Z0-9-./+_]+)\](#|\$)
# CentOS-7.4.1708
echo "export PS1='\[\e[1;32m\][\u@\h \W]\\$ \[\e[0m\]'" >> /etc/bashrc
cat << EOF >> /etc/fstab
UUID=2017-09-06-10-53-42-00 /mnt/cdrom iso9660 defaults 0 0
EOF
mkdir /mnt/cdrom && mount -a
rm -rf /etc/yum.repos.d/*
cat << EOF > /etc/yum.repos.d/CentOS-Media.repo
# CentOS-Media.repo
#
# This repo can be used with mounted DVD media, verify the mount point for
# CentOS-7. You can use this repo and yum to install items directly off the
# DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
# yum --enablerepo=c7-media [command]
#
# or for ONLY the media repo, do this:
#
# yum --disablerepo=\* --enablerepo=c7-media [command]
[c7-media]
name=CentOS-$releasever - Media
baseurl=file:///mnt/cdrom/
gpgcheck=0
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
EOF
yum clean all && yum makecache
sed -i "s/^#UseDNS.*/UseDNS no/g" /etc/ssh/sshd_config
sed -i "s/SELINUX=.*/SELINUX=disabled/g" /etc/selinux/config
systemctl stop firewalld && systemctl disable firewalld && rpm -e --nodeps firewalld
yum -y install iptables-services
systemctl start iptables && iptables -F && service iptables save
yum -y install lrzsz net-tools patch bash-completion vim tree \
wget dos2unix ntpdate unzip psmisc kernel-tools tcpdump mailx chrony
cat << EOF >> /etc/vimrc
set ts=4
EOF
vim /etc/chrony.conf
server cn.pool.ntp.org minpoll 4 maxpoll 10 iburst
server ntp.aliyun.com minpoll 4 maxpoll 10 iburst
server ntp1.aliyun.com minpoll 4 maxpoll 10 iburst
server ntp.tencent.com minpoll 4 maxpoll 10 iburst
systemctl restart chronyd.service && systemctl enable chronyd.service
# 检查同步状态
chronyc sources
timedatectl set-timezone Asia/Shanghai
# 修改主机名 hostnamectl set-hostname host-10-11
# 清除历史命令
# 重启系统
作者:Outsrkem
原文链接:https://www.cnblogs.com/outsrkem/p/11753139.html
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

浙公网安备 33010602011771号