• 系统初始化脚本


    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/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    win7下安装Linux实现双系统全攻略
    Dreamweaver_CS6安装与破解,手把手教程
    windows Server 2008各版本有何区别?
    如何查看路由器中的pppoe拨号密码?
    xp远程桌面连接最大用户数怎么设置?
    网站的盈利模式
    linux 下安装mysql-5.7.16
    GNS3连接虚拟机
    cain使用教程
    数据中心网络架构的问题与演进 — CLOS 网络与 Fat-Tree、Spine-Leaf 架构
  • 原文地址:https://www.cnblogs.com/outsrkem/p/11753139.html
Copyright © 2020-2023  润新知