------------恢复内容开始------------
话题1:linux系统最小化安装常用命令
Centos7,8系统最小化安装常用命令如下:
yum install vim iotop bc gcc gcc-c++ glibc glibc-devel pcre \ pcre-devel openssl openssl-devel zip unzip zlib-devel net-tools \ lrzsz tree ntpdate telnet lsof tcpdump wget libevent libevent-devel \ bc systemd-devel bash-completion traceroute -y
Ubuntu1804系统最小化安装常用命令如下:
apt install iproute2 ntpdate tcpdump telnet traceroute \
nfs-kernel-server nfs-common lrzsz tree openssl libssl-dev \
libpcre3 libpcre3-dev zlib1g-dev ntpdate traceroute gcc openssh-server \
lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump \
telnet traceroute iotop unzip zip -y
写一个脚本:实现自动判断是系统是centos,还是ubuntu,并完成上述最小化安装常用命令的过程:
1 [root@centos7 script]# cat min_install.sh 2 #!/bin/bash 3 # 4 #******************************************************************** 5 #Author: zouyongbing 6 #QQ: 273838882 7 #Date: 2021-12-03 8 #FileName: min_install.sh 9 #URL: https://www.cnblogs.com/zouyongbing/ 10 #Description: The test script 11 #Copyright (C): 2021 All rights reserved 12 #******************************************************************** 13 . /etc/os-release 14 min_install_yum(){ 15 yum install vim iotop bc gcc gcc-c++ glibc glibc-devel pcre \ 16 pcre-devel openssl openssl-devel zip unzip zlib-devel net-tools \ 17 lrzsz tree ntpdate telnet lsof tcpdump wget libevent libevent-devel \ 18 bc systemd-devel bash-completion traceroute -y 19 } 20 min_install_dnf(){ 21 dnf install vim iotop bc gcc gcc-c++ glibc glibc-devel pcre \ 22 pcre-devel openssl openssl-devel zip unzip zlib-devel net-tools \ 23 lrzsz tree ntpdate telnet lsof tcpdump wget libevent libevent-devel \ 24 bc systemd-devel bash-completion traceroute -y 25 } 26 min_install_apt(){ 27 apt install iproute2 ntpdate tcpdump telnet traceroute \ 28 nfs-kernel-server nfs-common lrzsz tree openssl libssl-dev \ 29 libpcre3 libpcre3-dev zlib1g-dev ntpdate traceroute gcc openssh-server \ 30 lrzsz tree openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev ntpdate tcpdump \ 31 telnet traceroute iotop unzip zip -y 32 } 33 judge_os(){ 34 if [ ${VERSION_ID} == "7" ];then 35 echo "你的操作系统是centos7,下面进行安装常用软件包:" 36 min_install_yum 37 echo "所有常用软件包已经安装完毕!请验证是否成功执行!!!" 38 elif [ ${VERSION_ID} == "8" ];then 39 echo "你的操作系统是centos8,下面进行安装常用软件包:" 40 min_install_dnf 41 echo "所有常用软件包已经安装完毕!请验证是否成功执行!!!" 42 elif [ ${VERSION_ID} == "18.04" ];then 43 echo "你的操作系统是ubuntu1804,下面进行安装常用软件包:" 44 min_install_apt 45 echo "所有常用软件包已经安装完毕!请验证是否成功执行!!!" 46 else 47 echo "不支持的操作系统,请手动安装" 48 fi 49 } 50 judge_os
------------恢复内容结束------------