ubuntu环境配置脚本

  • 运行脚本前期准备
    • 按需:下载nvidia-docker,放在~/Downloads目录下
    • 按需:建立Dockerfile文件,放在~/Downloads目录下
    • 按需:下载UltraEdit,放在~/Downloads目录下
    • 按需:下载bcompare,放在~/Downloads目录下
  • sudo apt-get update
    sudo apt-get install -y apt-transport-https
    sudo apt-get install -y ca-certificates
    sudo mv /etc/apt/sources.list /etc/apt/sources.list.bk
    touch ~/sources.list# ustc sources
    echo "deb https://mirrors.ustc.edu.cn/ubuntu/ $(lsb_release -c --short) main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ $(lsb_release -c --short) main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ $(lsb_release -c --short)-updates main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ $(lsb_release -c --short)-updates main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ $(lsb_release -c --short)-backports main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ $(lsb_release -c --short)-backports main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ $(lsb_release -c --short)-security main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ $(lsb_release -c --short)-security main restricted universe multiverse
    deb https://mirrors.ustc.edu.cn/ubuntu/ $(lsb_release -c --short)-proposed main restricted universe multiverse
    deb-src https://mirrors.ustc.edu.cn/ubuntu/ $(lsb_release -c --short)-proposed main restricted universe multiverse" > ~/sources.list# tsinghua sources
    # echo "deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -c --short) main restricted universe multiverse
    # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -c --short)-updates main restricted universe multiverse
    # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -c --short)-backports main restricted universe multiverse
    # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ $(lsb_release -c --short)-security main restricted universe multiverse" > ~/sources.list
    sudo mv ~/sources.list /etc/apt/sources.listsudo apt-get update
    sudo apt-get install -y net-tools
    sudo apt-get install -y language-pack-zh-hans
    sudo apt-get install -y locales
    sudo localedef -i zh_CN -c -f UTF-8 zh_CN.UTF-8
    sudo echo "export LC_ALL=zh_CN.UTF-8" >> /etc/profile
    sudo source /etc/profile
    sudo apt-get install -y wget
    sudo apt-get install -y python3
    sudo apt-get install -y vim 
    sudo apt-get instal -y openssh-server
    sudo apt-get install -y python3-pip
    sudo apt-get install -y git
    sudo apt-get install -y cmake
    sudo apt-get install -y gfortran
    sudo apt-get install -y pylint
    sudo apt-get install -y build-essential
    sudo apt-get install -y ninja-build
    sudo apt-get install -y ccache
    sudo apt-get install -y libopenblas-dev
    sudo apt-get install -y libopencv-dev
    sudo apt-get install -y module-init-tools
    sudo apt-get install -y libatlas-base-dev
    sudo apt-get install -y libxcb-icccm4-dev
    sudo apt-get install -y libxcb-image0
    sudo apt-get install -y libxcb-util1
    sudo apt-get install -y libxcb-keysyms1
    sudo apt-get install -y libxcb-randr0
    sudo apt-get install -y libxcb-render-util0
    sudo apt-get install -y libxcb-shape0
    sudo apt-get install -y libxcb-xkb1
    sudo apt-get install -y libxkbcommon-x11-dev
    sudo apt-get install -y libxcb-xinerama0
    sudo apt-get install -y openssh-server
    sudo apt-get install -y openssh-client
    sudo apt-get install -y tmux
    cd ~
    touch .vimrc
    echo "set nu\nset tabstop=4\nset shiftwidth=4\nset autoindent\nset smartindent \nset expandtab\nset hlsearch\nset incsearch\nset ignorecase" > /home/$USER/.vimrc
    # =======================prepare python environment============================================
    pip3 install --upgrade setuptools
    python3 -m pip install --upgrade pip
    if [ $(lsb_release -r --short) == '18.04' ]; then
    pip3 install opencv-python==3.2.0.8
    elif [ $(lsb_release -r --short) == '20.04' ]; then
    pip3 install opencv-python==3.4.8.29
    fi
    pip3 install numpy==1.19.5
    pip3 install PyQt5
    # =======================make user directory==================================================
    # /home/user
    path1="/home/$USER/software"
    if [ -d "$path1" ]; then
    echo "--------~/software exists------------------"
    else
    mkdir software
    fi
    path2="/home/$USER/code"
    if [ -d "$path2" ]; then
    echo "--------~/code exists------------------"
    else
    # /home/user
    mkdir code
    fi
    # =======================install chrome=======================================================
    cd software
    val=`ls ./*.deb |grep google-chrome-stable_current*.deb | wc -l`if [ $val -eq 0 ]; then
    # 64
    wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb 
    # 32
    # wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb
    else
    echo "------google-chrome package exists---------"
    fi
    sudo dpkg -i google-chrome*
    sudo apt-get -f -y install 
    # =======================prepare sogou environment============================================
    sudo apt-get purge ibus
    sudo apt-get install -y fcitx 
    sudo apt-get install -y fcitx-googlepinyin 
    sudo apt-get install -y fcitx-table-wbpy 
    sudo apt-get install -y fcitx-pinyin 
    sudo apt-get install -y fcitx-sunpinyin
    # =======================install docker=======================================================
    sudo apt-get remove -y docker 
    sudo apt-get remove -y docker-engine 
    sudo apt-get remove -y docker-ce 
    sudo apt-get remove -y docker.io
    sudo apt-get install -y curl 
    sudo apt-get install -y software-properties-common
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    sudo apt-get update
    sudo apt-get install -y docker-ce
    # =======================install nvidia docker=======================================================
    fileName1="~/Downloads/libnvidia-container-tools_1.0.1-1_amd64.deb"
    fileName2="~/Downloads/libnvidia-container1_1.0.1-1_amd64.deb"
    fileName3="~/Downloads/nvidia-container-toolkit_1.0.5-1_amd64.deb"
    fileName4="~/Downloads/nvidia-container-runtime_3.1.4-1_amd64.deb"
    if [ -f "$fileName1" -a -f "$fileName2" -a -f "$fileName3" -a -f "$fileName4" ]; then
    sudo dpkg -i ~/Downloads/libnvidia-container-tools_1.0.1-1_amd64.deb
    sudo dpkg -i ~/Downloads/libnvidia-container1_1.0.1-1_amd64.deb
    sudo dpkg -i ~/Downloads/nvidia-container-toolkit_1.0.5-1_amd64.deb
    sudo dpkg -i ~/Downloads/nvidia-container-runtime_3.1.4-1_amd64.deb
    fi
    sudo systemctl start docker
    sudo groupadd docker
    sudo gpasswd -a $USER docker
    sudo service docker restart
    # =======================install ultra edit=======================================================
    fileName5="~/Downloads/uex_20.00.0.34_amd64.deb"
    if [ -f "$fileName5" ]; then
    sudo dpkg -i ~/Downloads/uex_20.00.0.34_amd64.deb
    fi
    # =======================install beyond compare===================================================
    fileName6="~/Downloads/bcompare-4.3.7.25118_amd64.deb"
    if [ -f "$fileName6" ]; then
    sudo dpkg -i bcompare-4.3.7.25118_amd64.deb
    fi
    # =======================配置ssh_config===========================================================
    echo "ForwardAgent yes" |sudo tee -a /etc/ssh/ssh_config
    echo "ForwardX11 yes" |sudo tee -a /etc/ssh/ssh_config
    echo "ForwardX11Trusted yes" |sudo tee -a /etc/ssh/ssh_config
    # =======================配置sshd_config==========================================================
    echo "AllowAgentForwarding yes" |sudo tee -a /etc/ssh/sshd_config
    echo "AllowTcpForwarding yes" |sudo tee -a /etc/ssh/sshd_config
    echo "X11Forwarding yes" |sudo tee -a /etc/ssh/sshd_config
    echo "X11DisplayOffset 10" |sudo tee -a /etc/ssh/sshd_config
    echo "X11UseLocalhost yes" |sudo tee -a /etc/ssh/sshd_config
    echo "ClientAliveInterval 60" |sudo tee -a /etc/ssh/sshd_config
    echo "ClientAliveCountMax 3" |sudo tee -a /etc/ssh/sshd_config


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部