banner
The Commonly Used Commands in Windows.

Windows 中的常用命令

Scroll down

本文章整理归纳了一些 Windows 中常用的命令,Windows 与 Linux 部分命令名称相同,但是 Windows 命令直观上来看更加长但是命令名称更加直观。
在下文中,Windows 以 powershell 示例,Linux以 Ubuntu 系统 Bash 示例

在Windows中一行执行多个命令

不同命令之间使用;进行连接

1
mkdir build ; cd build

这样就可以创建并进入build文件夹了

文件、目录操作

操作 Windows (PowerShell) Linux (Bash)
当前目录 cd cd
列出文件 dir / ls (PowerShell 支持) ls
创建文件夹 mkdir 文件夹名 mkdir 文件夹名
删除文件夹 rmdir /s 文件夹名 rm -r 文件夹名
删除文件 del 文件名 / Remove-Item 文件名 rm 文件名
拷贝文件 copy / Copy-Item cp
移动文件 move / Move-Item mv
查看文件内容 type / Get-Content cat
创建文件 new-Item file.txt -ItemType file"" > file.txt touch file.txt
创建带内容文件 Set-Content hello.txt "Hello" echo "Hello" > hello.txt
追加内容 echo Another line >> file.txt echo "Another line" >> file.txt
编辑文件 notepad file.txt nano/vim file.txt

查找文件与内容

操作 Windows Linux
按名称查找文件 PowerShell: Get-ChildItem -Recurse -Filter 文件名 find . -name "文件名"
按内容查找文件 Select-String -Pattern "关键词" grep "关键词" 文件名
查找文件中包含关键词的文件 findstr /s /m "关键词" * grep -rl "关键词" .

创建或解压

操作 Windows Linux
创建 zip 文件 Compress-Archive -Path .\folder -DestinationPath out.zip zip -r out.zip folder
解压 zip 文件 Expand-Archive out.zip -DestinationPath folder unzip out.zip
解压 tar.gz 文件 需要 7-Zip 或 tar tar -xzvf file.tar.gz

软件管理

操作 Windows Linux
包管理 winget install xxxchoco install xxx(需安装) apt install
查看已安装包 winget list dpkg -l / apt list --installed

系统/进程管理

操作 Windows Linux
查看进程 tasklist / Get-Process ps / top / htop
结束进程 taskkill /PID 1234 kill 1234
查看IP ipconfig ifconfigip a
查看端口 netstat -an netstat -anss -tuln
启动服务 net start 服务名 systemctl start 服务名
停止服务 net stop 服务名 systemctl stop 服务名

网络相关操作

操作 Windows Linux
ping ping www.google.com ping www.google.com
下载文件 Invoke-WebRequest / curl wget / curl
DNS测试 nslookup 域名 nslookupdig

清屏操作

操作 Windows Linux
清屏 cls/clear clear
其他文章
cover
CS61B中的归并排序和插入排序
  • 25/07/24
  • 23:58
  • 数据结构
cover
CS61B中的堆以及堆排序算法
  • 25/07/22
  • 23:57
  • 数据结构
30+
Posts
8+
Diary
85+
fans
目录导航 置顶
  1. 1. 在Windows中一行执行多个命令
  2. 2. 文件、目录操作
  3. 3. 查找文件与内容
  4. 4. 创建或解压
  5. 5. 软件管理
  6. 6. 系统/进程管理
  7. 7. 网络相关操作
  8. 8. 清屏操作