Files
linux-odyssey/quests/path/game.yml
T
2023-11-23 15:06:34 +08:00

189 lines
5.8 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
title: 檔案路徑
instruction: |
在這個關卡中,你將會學到:
1. 絕對路徑和相對路徑
2. 如何使用 `pwd` 顯示目前的路徑
請輸入 `echo start` 來開始這一關。
requirements:
- cast
- explore
stages:
- id: warning-01
repeatable: true
condition:
command:
- ' '
hints:
- '!! 請勿使用全形空格 !!'
- id: start
task: 輸入 `echo start` 來開始教程
repeatable: false
condition:
output:
- ^start$
responses:
- content:
- 在 Linux 系統中,每個資料夾和檔案都有獨一無二的路徑。
- 而路徑又分為相對路徑和絕對路徑。
- 相對路徑是從目前所在的資料夾開始的路徑,而絕對路徑則是從根目錄開始的路徑。
- 你在之前使用的 `cd folder` 或 `cd ..` ,後面的 `folder` 和 `..` 就是相對路徑。
- 你可以使用 `pwd` 指令來顯示目前所在的絕對路徑。
- '`pwd` 是 print working directory 的縮寫,也就是顯示目前所在的路徑的意思。'
- 現在,請你輸入 `pwd` 指令,查看目前所在的絕對路徑。
hints:
- ➤ 輸入 `pwd` 查看目前所在的絕對路徑
- id: pwd
task: 查看資料夾中的檔案
requirements:
- start
condition:
command:
- ^ls$
responses:
- content:
- 你應該能看到資料夾中的內容了。
- 在畫面右邊的檔案樹也有了改變。
- 可以看出,在這個資料夾中包含了兩個資料夾,分別是 `folder1` 和 `folder2`。
- content:
- 接下來,我要教你如何進入資料夾。
- '`cd` 指令是 change directory 的縮寫,也就是改變路徑的意思。'
- 你可以通過輸入 `cd [資料夾名稱]` 來進入資料夾。
- 例如你要進入 `folder1` 資料夾,你可以輸入
- '`cd folder1`。'
- 現在,請你進入 `folder1` 資料夾。
hints:
- ➤ 輸入 `cd folder1` 來進入 `folder1` 資料夾
exceptions:
- condition:
not:
pwd:
- /home/commander
hints:
- ➤ 請先回到 `/home/commander/` 資料夾
- ➤ 輸入 `cd ~` 來返回 `/home/commander/` 資料夾
- condition:
command:
- ^[Ii]s$
hints:
- '!! `ls` 的首字母是小寫的 `L`,不是 `I` !!'
- id: cd-folder1
task: 進入 `folder1` 資料夾
requirements:
- ls
condition:
pwd:
- /home/commander/folder1
responses:
- content:
- 你成功的進入 `folder1` 資料夾了。
- 你可以發現指令提示符從原本的
- '`commander:~ $` 變成了'
- '`commander:~/folder1 $` 。'
- 這表示你現在正位在 `folder1` 資料夾中。
- 現在,請查看 `folder1` 資料夾的內容。
hints:
- ➤ 輸入 `ls` 查看資料夾的內容
exceptions:
- condition:
pwd:
- /home/commander
hints:
- ➤ 輸入 `cd folder1` 來進入 `folder1` 資料夾
- condition:
not:
pwd:
- /home/commander
hints:
- ➤ 請先回到 `/home/commander/` 資料夾
- ➤ 輸入 `cd ~` 來返回 `/home/commander/` 資料夾
- id: ls-folder1
task: 查看 `folder1` 資料夾的內容
repeatable: false
requirements:
- cd-folder1
condition:
pwd:
- /home/commander/folder1
command:
- ls
responses:
- type: narrative
content:
- 你現在可以看到 `folder1` 資料夾中有兩的檔案,分別是 `file1.txt` 跟 `file2.txt`。
- 現在我們可以離開 `folder1` 回到原本的資料夾了。
- 你可以使用 `cd ..` 回到上一層資料夾。
- 這裡的 `..` 代表的是上一層的資料夾。
hints:
- 輸入 `cd ..` 回到上一層資料夾
- id: cd-..
task: 回到上一層資料夾
requirements:
- ls-folder1
condition:
pwd:
- /home/commander
responses:
- type: narrative
content:
- 你成功的回到上一層資料夾了。
- 現在,請你剛才所學的指令,進入 `folder2` 資料夾,檢查 `folder2` 資料夾的內容,最後回到這個資料夾。
hints:
- ➤ 使用 `cd` 指令進出資料夾
- ➤ 使用 `ls` 指令查看資料夾的內容
- id: cd-folder2
task: 進入 `folder2` 資料夾
requirements:
- cd-..
condition:
pwd:
- /home/commander/folder2
responses:
- content:
- 你成功的進入 `folder2` 資料夾了。
- 現在,請你查看 `folder2` 資料夾的內容。
hints:
- ➤ 使用 `ls` 查看資料夾的內容
- id: ls-folder2
task: 查看 `folder2` 資料夾的內容
requirements:
- cd-folder2
condition:
pwd:
- /home/commander/folder2
command:
- ls
responses:
- type: narrative
content:
- 你看到了 `folder2` 資料夾中的檔案,分別是 `file3.txt` 跟 `file4.txt`。
- 現在你可以離開 `folder2` 回到原本的資料夾了。
hints:
- ➤ 使用 `cd ..` 回到上一層資料夾
- id: END
task: 回到原本的資料夾
requirements:
- ls-folder2
condition:
pwd:
- /home/commander
responses:
- type: narrative
content:
- 你成功的回到原本的資料夾了。
- 恭喜你學會了 `ls` 和 `cd` 指令的用法。
hints:
- ➤ 使用 `cd` 指令進出資料夾
- ➤ 使用 `ls` 指令查看資料夾的內容