cd
文件与目录
用法
cd [path]切换 shell 的当前目录;它是 shell 内建命令,所以脚本或子 shell 里的 cd 不会影响外面的 shell。
常用选项
| 选项 | 含义 |
|---|---|
| - | An argument rather than a flag: return to the previous directory |
| ~ | Your home directory; ~user is another user home |
| -P | Move to the real directory, resolving symlinks |
| -L | Keep the symlinked path (the default) |
示例
cd -Jump back to where you just were.
cd ..Up one level.
cdWith no argument at all, go home.
移动、删除和查找。有些命令不会再问一遍,所以顺手加 -i 是在救自己。
怎么看
- 方括号 [ ] 表示这部分可以不写。
- 省略号 … 表示可以写多个。
- 选项区分大小写——有些命令里 -r 和 -R 不是一回事。
常见问题
Q. cd 是做什么的?
切换 shell 的当前目录;它是 shell 内建命令,所以脚本或子 shell 里的 cd 不会影响外面的 shell。
Q. 怎么写?
cd [path] —— 方括号表示可以省略的部分。
Q. 值得记的选项有几个?
这里列了 4 个,完整列表在 man cd。这条命令属于文件与目录。
相关命令
man 手册: man cd