基本导航:`cd`、`ls`、`pwd`
学习在文件系统中移动、列出目录内容,并确定当前所在位置。
基本导航:`cd`、`ls`、`pwd` 是 CoddyKit 上的免费 Linux Command Line Mastery 课时。 这是第 2 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Linux Command Line Mastery 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Linux Command Line Mastery 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
Navigating Your Linux System
The Linux file system is a tree rooted at /. This lesson covers the commands to move around it and see what’s inside each directory.
Where Am I? The `pwd` Command
Lost your place? pwd (print working directory) shows the full path of where you are right now — your “you are here” sign.
See Your Current Path with `pwd`
Run pwd to see your current directory — likely something like /home/user.
pwdWhat's Here? The `ls` Command
ls (list) shows the files and folders in your current directory — or any directory you point it at.
Listing Directory Contents with `ls`
Let’s make a folder and a file, then run ls to watch them show up.
mkdir my_documents
touch notes.txt
lsMoving Around: The `cd` Command
cd (change directory) moves you around the file system. Give it an absolute path (from /) or a relative one (from where you are).
Changing with Absolute Paths
An absolute path starts at the root /, so it always points to the same place no matter where you currently are.
mkdir -p /tmp/my_project/src
cd /tmp/my_project/src
pwdChanging with Relative Paths
A relative path starts from your current spot — shorter and handy. Use . for here and .. for the parent directory.
mkdir -p project/images
cd project
pwd
cd images
pwd
cd ..
pwdUseful `ls` Options: `-l` and `-a`
Two essential ls flags: -l for a long listing (permissions, size, date) and -a to reveal hidden dotfiles.
touch .config_file
touch public_file
ls -a
ls -lTest Your Navigation Skills
Consider the following sequence of commands executed in a terminal:
mkdir my_app
cd my_app
mkdir assets
touch assets/image.png
cd ..
lsRecap: Navigate Like a Pro!
Navigation locked in! pwd shows where you are, ls lists contents, and cd moves you around with absolute or relative paths.
常见问题解答
「基本导航:`cd`、`ls`、`pwd`」课时是免费的吗?
是的 — 「基本导航:`cd`、`ls`、`pwd`」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Linux Command Line Mastery 课程的其余内容,请升级到 CoddyKit PRO。 Linux Command Line Mastery 课程共包含 4 节课。
「基本导航:`cd`、`ls`、`pwd`」这节课中我会学到什么?
学习在文件系统中移动、列出目录内容,并确定当前所在位置。 你通过在浏览器中直接运行的动手代码来练习 Linux Command Line Mastery,全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 Linux Command Line Mastery 需要有经验吗?
无需任何先前经验。CoddyKit 上的 Linux Command Line Mastery 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 2 节课,共 4 节。
「基本导航:`cd`、`ls`、`pwd`」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 Linux Command Line Mastery 课中编写并运行代码吗?
能。每节 Linux Command Line Mastery 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- Linux Shell 入门
- 基本导航:`cd`、`ls`、`pwd`
- 文件与目录管理:`mkdir`、`rm`、`cp`、`mv`
- 获取帮助:man、--help 与 tldr