如何区分你当前使用的 Linux 系统是 Ubuntu、CentOS 还是 Alpine,查看 /etc/os-release 文件
[root@localhost ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
[root@localhost ~]#
1:linux环境提示/bash: telnet: not found,执行以下其中之一定有一个行
Debian/Ubuntu:apt-get update && apt-get install telnet
CentOS/RHEL:yum install telnet
Alpine:apk update && apk add telnet 注意:Alpine Linux 使用的是 apk 包管理器
2:linux环境提示/bash: curl: not found
Debian/Ubuntu:sudo apt-get update && sudo apt-get install curl
CentOS/RHEL:yum install curl
Alpine:apk update &&apk add --no-cache curl 注意:Alpine Linux 使用的是 apk 包管理器
3:容器环境提示/bin/sh: telnet: not found,先执行apk update,再执行apk add busybox-extras
/test # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
afetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
v3.9.6-143-ga5f34edab6 [http://dl-cdn.alpinelinux.org/alpine/v3.9/main]
v3.9.6-138-ge069a77b3b [http://dl-cdn.alpinelinux.org/alpine/v3.9/community]
OK: 9793 distinct packages available
/test #
/test # apk add busybox-extras
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/1) Installing busybox-extras (1.29.3-r10)
Executing busybox-extras-1.29.3-r10.post-install
Executing busybox-1.29.3-r10.trigger
OK: 103 MiB in 55 packages
/test #
4:容器环境提示/bin/sh: curl: not found,执行apk add --no-cache curl
/test # apk add --no-cache curl
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/4) Installing nghttp2-libs (1.35.1-r2)
(2/4) Installing libssh2 (1.9.0-r1)
(3/4) Installing libcurl (7.64.0-r5)
(4/4) Installing curl (7.64.0-r5)
Executing busybox-1.29.3-r10.trigger
OK: 104 MiB in 59 packages
/test #