首页/系统/信创系统运维速查/PowerShell 与 bash 常用命令对照
迁移适配65 条

PowerShell 与 bash 常用命令对照

从 Windows 转过来的运维视角:进程、服务、网络、文本处理的高频命令一一对照,降低迁移期记忆成本。

信创系统运维速查系统更新于 2026-10-12

常用对照

用途PowerShellbash(信创)
列文件Get-ChildItemls / find
进程Get-Processps -ef / top
服务Get-Servicesystemctl
磁盘Get-Volumedf -h / lsblk
连通测试Test-NetConnectionping / nc -vz
文本搜索Select-Stringgrep -r
计划任务Get-ScheduledTaskcrontab -l / systemctl list-timers

示例

示例
# PowerShell: Get-Process | Where-Object CPU -gt 60
ps -eo pid,pcpu,comm --sort=-pcpu | head
# PowerShell: Test-NetConnection 10.0.0.9 -Port 443
nc -vz 10.0.0.9 443
管道语义不同:bash 处理文本流、PowerShell 处理对象;复杂脚本建议重写而非逐行翻译。

易错点

  • 通配符与引号规则差异大:shell 先展开、PowerShell 传对象,逐行翻译容易翻车
  • 重写脚本时补 set -euo pipefail 等防护,别只复刻功能

数据来源与参考

  • Microsoft Learn(PowerShell 参考)
  • man 1 bash
​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌