• 系统初始化脚本


    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 patch bash-completion vim tree wget dos2unix ntpdate unzip psmisc  kernel-tools  tcpdump mailx
    
    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 iburst
    server ntp.aliyun.com iburst 
    server ntp1.aliyun.com iburst
    server ntp2.aliyun.com iburst
    server ntp3.aliyun.com iburst
    server ntp4.aliyun.com iburst
    server ntp5.aliyun.com iburst
    server ntp6.aliyun.com iburst
    
    systemctl restart chronyd.service && systemctl enable chronyd.service
    
    timedatectl set-timezone Asia/Shanghai
    
    # 修改主机名 hostnamectl set-hostname host-10-11
    # 清除历史命令
    # 重启系统


    作者:Outsrkem
    出处:https://www.cnblogs.com/outsrkem/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    js实现继承的5种方式
    JavaScript文件操作(1)-基础
    12 个免费在线的 Web 网站性能测试工具
    server r2 系统更新文件清理
    在C#中,Json的序列化和反序列化的几种方式总结
    ES6,新增数据结构Set的用法
    ES6中有关数组的一些新操作
    vue中mode hash 和 history的区别
    POST和GET的区别
    前端的细节
  • 原文地址:https://www.cnblogs.com/outsrkem/p/11753139.html
Copyright © 2020-2023  润新知