Last active 1748146268

check.sh Raw
1#!/usr/bin/env bash
2set -euo pipefail
3
4# 要检查的命令列表(包含常用的系统管理、文件操作、网络诊断等)
5cmds=(
6 # 原有命令
7 ls type which make uname lsb_release usermod nano apt sudo
8 dirname basename yes printf stat diff patch dpkg dpkg-query apt-cache
9 rsync id groups smartctl mkfs.ext4 strace nmap rsync
10 tar xz gzip file less w who whoami scp vim
11 lspci lsusb lsblk fdisk df free top htop ip ping curl wget
12 zip unzip xargs tar time zstd ssh adduser ufw man
13 mount umount systemctl journalctl dmesg hostname hostnamectl
14 cat echo grep awk sed cut find ps less kmod iptables ip6tables
15 netstat ss route tcpdump du chmod chown cp mv rm mkdir rmdir ln touch
16 useradd userdel groupadd groupdel passwd su sudo env uname whoami
17 uptime date lsof vmstat iostat traceroute host dig
18 tail head watch logger crontab ifconfig
19)
20
21for cmd in "${cmds[@]}"; do
22 if ! command -v "$cmd" >/dev/null 2>&1; then
23 echo "ERROR: Required command '$cmd' not found in \$PATH!" >&2
24 exit 1
25 fi
26done
27
28echo "✅ 系统健康检查通过:所有常用命令都可用。"
29