• ubuntu-18.04自动配置脚本


    使用ubuntu server的alternate installer版本

    #!/bin/bash
    
    echo "blacklist i2c_piix4"  >> /etc/modprobe.d/blacklist.conf
    
    currentTime=$(date +"%Y-%m-%d_%H:%M:%S")
    
    sed -i '/UseDNS yes/s/^/#/' /etc/ssh/sshd_config
    sed -i '/#UseDNS yes/a UseDNS no' /etc/ssh/sshd_config
    sed -i '/#PubkeyAuthentication yes/s/^#//' /etc/ssh/sshd_config
    
    sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak@$currentTime
    
    sudo cat > /etc/apt/sources.list << EOF
    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    
    deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    EOF
    
    
    touch /etc/sudoers.d/nopasswd4sudo
    echo "ubuntu ALL=(ALL) NOPASSWD : ALL"  >> /etc/sudoers.d/nopasswd4sudo
    
    
    ##network_config
    NIC_CONF="/etc/netplan/01-netcfg.yaml"
    NIC_NAME="ens32"
    
    HOST_NAME="vhost"
    NIC_IP="192.168.127.20"
    GATWAY="192.168.127.254"
    DNS1="114.114.114.114"
    DNS2="8.8.8.8"
    SUBNET="24"
    
    mv $NIC_CONF $NIC_CONF'.bak@'$currentTime
    
    cat > $NIC_CONF <<EOF
    network:
        ethernets:
            ens32:
                addresses:
                - $NIC_IP/$SUBNET
                dhcp4: false
                dhcp6: false
                gateway4: $GATWAY
                nameservers:
                    addresses:
                    - $DNS1
                    - $DNS2
                    search: []
        version: 2
    EOF
    
    mv /etc/hosts /etc/host.bak@$currentTime
    cat > /etc/hosts << EOF
    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    
    127.0.0.1       localhost
    EOF
    
    echo "$NIC_IP      $HOST_NAME " >> /etc/hosts
    hostnamectl set-hostname $HOST_NAME
    
    # netplan apply
    
    # apt-get update
    # apt-get upgrade
    # apt-get install build-essential
    
    
  • 相关阅读:
    电信生命周期说明
    find in linux 2 微信公众号
    GDB中应该知道的几个调试方法 2 微信公众号
    linux 下程序员专用搜索源码用来替代grep的软件ack(后来发现一个更快的: rg), 且有vim插件的 2 微信公众号
    linux下的 c 和 c++ 开发工具及linux内核开发工具 2 微信公众号
    linux下命令行发送邮件的软件:mutt 微信公众号
    腺样体肿大的综合治疗考虑 微信公众号
    打呼噜治疗方法 微信公众号
    vim 操作 2 微信公众号
    nginx之外的web 服务器caddy 微信公众号
  • 原文地址:https://www.cnblogs.com/javaite/p/9833976.html
Copyright © 2020-2023  润新知