1.VibeCoding 终端命令基础使用

24 阅读2分钟

1.切换目录

cd 文件夹名        # 进入当前目录下的某个文件夹
cd ..              # 返回上级目录
cd ~               # 回到用户主目录(Mac/Linux / PowerShell)
cd /               # 回到根目录(Mac/Linux)
cd D:              # Windows 切换盘符(仅 CMD)

示例

  • Windows CMD:cd C:\Users\你的用户名\Documents
  • Mac/Linux:cd /Users/你的用户名/Documentscd ~/Documents

2.列出当前目录内容 – ls / dir

系统命令说明
Windows (CMD)dir列出文件和文件夹
Windows (PowerShell)ls推荐,更接近 Linux
Mac / Linuxls列出
常用参数(Mac/Linux)ls -l(详细信息) ls -a(包含隐藏文件)

3.创建目录

系统命令
Windows (CMD)mkdir 文件夹名
Windows (PowerShell)mkdir 文件夹名New-Item -ItemType Directory 文件夹名
Mac / Linuxmkdir 文件夹名

4.创建空文件

系统命令
Windows (CMD)del 文件名
Windows (PowerShell)Remove-Item 文件名(也可用 del
Mac / Linuxrm 文件名

5.删除空目录

系统命令
Windows (CMD)rmdir 文件夹名
Windows (PowerShell)Remove-Item 文件夹名
Mac / Linuxrmdir 文件夹名(仅空目录) rm -r 文件夹名(删除目录及其内容,谨慎使用

6.查看文件内容

系统命令说明
Windows (CMD)type 文件名.txt打印内容到屏幕
Windows (PowerShell)cat 文件名.txtGet-Content
Mac / Linuxcat 文件名.txt打印全部内容
Mac / Linuxless 文件名.txt分页浏览(按 q 退出)
Mac / Linuxhead -n 5 文件名.txt查看前5行

7.清屏

系统命令
Windows (CMD)cls
Windows (PowerShell)clsClear-Host
Mac / LinuxclearCtrl + L

8.常用快捷键(通用)

快捷键作用
Tab自动补全路径/命令(极其常用
/ 翻阅之前输入过的命令
Ctrl + C终止当前正在运行的程序(卡住时用)
Ctrl + L清屏(Mac/Linux 及 PowerShell)
Ctrl + A/ Ctrl + E光标移到行首 / 行尾
Ctrl + R搜索历史命令(Mac/Linux)

:: 回家(用户根目录)
cd %USERPROFILE%

:: 创建练习文件夹
mkdir claude-practice

:: 进入文件夹
cd claude-practice

:: 创建空文件
type nul > hello.txt

:: 查看目录文件
dir

:: 写入内容到文件
echo Hello Claude > hello.txt

:: 读取文件内容
type hello.txt

:: 返回上级目录
cd ..

:: 删除文件夹(谨慎执行,会直接删除不提示)
rmdir /s /q claude-practice

Mac/Linux 练习

cd ~                      # 回家
mkdir claude-practice     # 创建练习文件夹
cd claude-practice        # 进入
touch hello.txt           # 创建文件
ls                        # 看到 hello.txt
echo "Hello Claude" > hello.txt   # 写入内容
cat hello.txt             # 查看内容
cd ..                     # 返回上级
rm -r claude-practice     # 删除练习(谨慎)
操作Windows (CMD)Mac / Linux
切换目录cdcd
列出文件dirls
创建目录mkdirmkdir
创建文件type nul > 文件touch
删除文件delrm
查看文件typecat
清屏clsclear
自动补全TabTab
历史命令