附录Shell 命令参考

网络与脚本命令

网络

命令用法
ifconfigifconfig [interface ...]
ifup / ifdownifup <interface>
pingping [-c <count>] [-i <interval>] [-W <timeout>] [-s <size>] <host>
nslookupnslookup <hostname>
wgetwget [-o <local-path>] <url>
arparp [-i <ifname>] [-a|-d|-s <ipaddr> [hwaddr]]

变量与脚本

命令用法
setset [{+|-}{e|x}] [<name> <value>]
unsetunset <name>
echoecho [-n] [<string|$name> ...]
printfprintf <string> [args ...](格式符不完全生效)
exprexpr <expression>
test / [test <expression>
true / false返回 0 / 1
source / .source <file>
execexec <cmd>
alias / unaliasalias [name[=value]]

系统控制

命令用法
rebootreboot,会直接重启设备
poweroffpoweroff,会直接关机
timedatectltimedatectl [set-timezone TZ]

压缩与归档

命令用法
tartar [-C rootdir] [-g] [-z] <-x|-t|-c> filename.tar [...]
gzipgzip <file>,无参数运行时可能阻塞
unzipunzip <file.zip>

使用建议

  • 网络连通性排查可以从 ifconfig、ifup、ping、nslookup 这条链路开始。
  • 简单脚本优先用 source 加 set/test/expr,避免使用桌面 shell 常见但这里不支持的语法。
  • reboot 和 poweroff 建议只在确认环境安全时执行。

大纲