122 lines
4.7 KiB
Plaintext
122 lines
4.7 KiB
Plaintext
{
|
||
"meta": {
|
||
"version": "1.0",
|
||
"title": "Linux 命令学习课程 - 沙盒练习题",
|
||
"author": "Dev Agent",
|
||
"created": "2026-03-04"
|
||
},
|
||
"levels": [
|
||
{
|
||
"id": "level_1_intro",
|
||
"title": "入门篇:熟悉终端",
|
||
"description": "前5个命令,让你快速上手 Linux 终端",
|
||
"challenges": [
|
||
{
|
||
"id": "pwd_1",
|
||
"title": "我在哪?",
|
||
"description": "使用 `pwd` 命令查看你当前所在的目录",
|
||
"hint": "直接输入 pwd 回车",
|
||
"success_test": "if output == '/' then pass",
|
||
"solution": ["pwd"],
|
||
"fail_message": "❌ 还不对!试试 `pwd` 命令"
|
||
},
|
||
{
|
||
"id": "ls_1",
|
||
"title": "看看周围",
|
||
"description": "使用 `ls` 命令列出 `/sandbox` 下的所有子目录和文件",
|
||
"hint": "输入 ls /sandbox",
|
||
"success_test": "if output contains 'users' and 'projects' and 'logs' then pass",
|
||
"solution": ["ls /sandbox", "ls /"],
|
||
"fail_message": "❌ 还差一点!试试 `ls /sandbox` 或 `ls /`"
|
||
},
|
||
{
|
||
"id": "cd_1",
|
||
"title": "进入用户区",
|
||
"description": "使用 `cd` 命令进入 /users 目录",
|
||
"hint": "先 cd 进去,再用 pwd 确认",
|
||
"success_test": "if cwd == '/users' then pass",
|
||
"solution": ["cd /users", "cd /"],
|
||
"fail_message": "❌ 还没到 /users!试试 `cd /users`"
|
||
},
|
||
{
|
||
"id": "cat_1",
|
||
"title": "读取文件",
|
||
"description": "使用 `cat` 命令读取 /users/alice.txt 的内容",
|
||
"hint": "cat /users/alice.txt",
|
||
"success_test": "if output contains 'Alice' and 'Linux' then pass",
|
||
"solution": ["cat /users/alice.txt"],
|
||
"fail_message": "❌ 记得完整路径!试试 `cat /users/alice.txt`"
|
||
},
|
||
{
|
||
"id": "echo_1",
|
||
"title": "打招呼",
|
||
"description": "使用 `echo` 打印一句话:Hello Linux!",
|
||
"hint": "echo 黑客996",
|
||
"success_test": "if output contains 'Hello Linux' then pass",
|
||
"solution": ["echo Hello Linux!", "echo 'Hello Linux!'"],
|
||
"fail_message": "❌ 别忘了空格!试试 `echo Hello Linux!`"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"id": "level_2_files",
|
||
"title": "文件操作",
|
||
"description": "创建、复制、移动、查看文件内容(只读沙盒)",
|
||
"challenges": [
|
||
{
|
||
"id": "tail_1",
|
||
"title": "看文件末尾",
|
||
"description": "使用 `tail -n 3` 查看 /projects/backend/app.py 的最后 3 行",
|
||
"hint": "tail -n 3 /projects/backend/app.py",
|
||
"success_test": "if output contains 'main' then pass",
|
||
"solution": ["tail -n 3 /projects/backend/app.py"],
|
||
"fail_message": "❌ 记得 `-n` 参数!试试 `tail -n 3`"
|
||
},
|
||
{
|
||
"id": "head_1",
|
||
"title": "看文件开头",
|
||
"description": "使用 `head -n 2` 查看 /logs/access.log 的前 2 行",
|
||
"hint": "head -n 2 /logs/access.log",
|
||
"success_test": "if output contains '2024-01-01' then pass",
|
||
"solution": ["head -n 2 /logs/access.log"],
|
||
"fail_message": "❌ 别忘了 `-n 2`!试试 `head -n 2`"
|
||
},
|
||
{
|
||
"id": "mkdir_1",
|
||
"title": "创建目录",
|
||
"description": "使用 `mkdir` 在 /projects 下创建一个叫 mycode 的目录",
|
||
"hint": "mkdir /projects/mycode",
|
||
"success_test": "if output contains 'mycode' then pass",
|
||
"solution": ["mkdir /projects/mycode"],
|
||
"fail_message": "❌ 路径别写错!试试 `mkdir /projects/mycode`"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"id": "level_3_search",
|
||
"title": "搜索高手",
|
||
"description": "grep/fun/wc/sort 组合技",
|
||
"challenges": [
|
||
{
|
||
"id": "grep_1",
|
||
"title": "查找关键词",
|
||
"description": "使用 `grep` 在 /users/alice.txt 中查找包含 'Linux' 的行",
|
||
"hint": "grep Linux /users/alice.txt",
|
||
"success_test": "if output contains 'Linux' then pass",
|
||
"solution": ["grep Linux /users/alice.txt"],
|
||
"fail_message": "❌ 格式是 `grep pattern file`!试试 `grep Linux`"
|
||
},
|
||
{
|
||
"id": "wc_1",
|
||
"title": "统计行数",
|
||
"description": "统计 /projects/backend/app.py 的总行数",
|
||
"hint": "wc -l /projects/backend/app.py",
|
||
"success_test": "if output contains '4' then pass",
|
||
"solution": ["wc -l /projects/backend/app.py"],
|
||
"fail_message": "❌ `-l` 是行数参数!试试 `wc -l`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|