最简单的
- 适合用于跟着别人的教程学东西
- 去除开机免密码登录
- 调整开机等待时间
- 关闭 SELINUX
- 调整时区 ```bash
__set_boot(){ sed -i ‘s,^ExecStart=.$,ExecStart=-/sbin/agetty —autologin root —noclear %I,’ /etc/systemd/system/getty.target.wants/getty@tty1.service sed -i ‘s,^ExecStart=.$,ExecStart=-/sbin/agetty —autologin root —noclear %I,’ /lib/systemd/system/autovt@.service
修改CentOS 选择内核界面的选择时间, 减少系统启动等待时间
sed -i ‘s,timeout=5$,timeout=1,’ /boot/grub2/grub.cfg 2>/dev/null sed -i ‘s,timeout=5$,timeout=1,’ /boot/efi/EFI/centos/grub.cfg 2>/dev/null } __set_boot
__set_config() { firewall-cmd —state systemctl stop firewalld.service systemctl disable firewalld.service
chkconfig NetworkManager offservice NetworkManager stopsetenforce 0sed -i 's,^SELINUX=.*$,SELINUX=disabled,' /etc/selinux/config
} __set_config
__set_time() {
# 设置时区rm -rf /etc/localtimeln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
} __set_time
<a name="PXVrj"></a># 升级内核```bash__kernel_update() {#导入公钥rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org#添加YUM源yum install -y https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm#安装更新长期支持版内核yum install -y --enablerepo=elrepo-kernel kernel-lt kernel-lt-devel#更新GRUB配置使用新内核启动#查看配置中的所有内核版本awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg_modify=$(awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg | head -1 | grep "$(uname -r)" -c)if ((_modify != 1)); then#设置新内核为默认启动项,默认情况下新内核序号为0grub2-set-default 0#更新配置grub2-mkconfig -o /boot/grub2/grub.cfg# 设置开机免输入密码sed -i 's,^ExecStart=.*$,ExecStart=-/sbin/agetty --autologin root --noclear %I,' /etc/systemd/system/getty.target.wants/getty@tty1.servicesed -i 's,^ExecStart=.*$,ExecStart=-/sbin/agetty --autologin root --noclear %I,' /lib/systemd/system/autovt@.service# 修改系统启动等待时间sed -i 's,timeout=5$,timeout=2,' /boot/grub2/grub.cfgsed -i 's,timeout=5$,timeout=2,' /boot/efi/EFI/centos/grub.cfgsync# rebootfi}__kernel_update
安装基础软件包
__install_app() {yum clean allyum makecache fastyum -y updateyum groups install -y baseyum -y install \vim git jq bc tree unzip zip dos2unix sysstat psmisc lsof sshpass expect \vnstat htop perf dstat glances \hdparm libaio-devel log4cplus log4cplus-devel lshw ntp xfsprogs-devel \net-tools bridge-utils nfs-utils telnet lrzsz \bash-completion bash-completion-extras}__install_app
二维码生成工具
qrencode
