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