{ "id": "linux-inspect-hardware", "title": "Inspect What This Machine Actually Has", "category": "Linux Fundamentals", "isolation_type": "shared_namespace", "difficulty": "Easy", "type": "task", "weight": 3, "description": "## Inspect What This Machine Actually Has\n\nThe kernel manages CPU, memory, and storage on behalf of every process running here — before you go further, look at what's actually available.\n\n**Your task:**\n\n1. Find the number of CPUs available (`nproc`)\n2. Find the total memory in MB (`free -m`)\n3. Find the size of the root filesystem in GB (`df -BG /`)\n4. Create a file at `/srv/hardware-lab/report.txt` with exactly three lines in this format (replace `` with the real numbers you found):\n\n```\nCPUS=\nMEM_MB=\nDISK_GB=\n```", "hints": [ { "title": "Getting each number", "body": "`nproc` alone prints the CPU count. `free -m` prints a table — the second column of the `Mem:` row is total memory in MB. `df -BG /` prints a table — the second column of the second row is the root filesystem size in GB (the number, not including the trailing G).", "command": "nproc; free -m; df -BG /" }, { "title": "Writing the report", "body": "Use a heredoc or several `echo` lines with `>>` to build the file.", "command": "mkdir -p /srv/hardware-lab && cat < /srv/hardware-lab/report.txt\nCPUS=$(nproc)\nMEM_MB=$(free -m | awk '/Mem:/ {print $2}')\nDISK_GB=$(df -BG / | awk 'NR==2{gsub(\"G\",\"\",$2); print $2}')\nEOF" } ], "setup_commands": [ { "command": "mkdir -p /srv/hardware-lab" } ], "validation": { "commands": [ { "description": "report.txt exists and has a CPUS line", "command": "grep -E '^CPUS=[0-9]+$' /srv/hardware-lab/report.txt", "expected_output": "^CPUS=[0-9]+$", "match": "regex" }, { "description": "report.txt has a MEM_MB line", "command": "grep -E '^MEM_MB=[0-9]+$' /srv/hardware-lab/report.txt", "expected_output": "^MEM_MB=[0-9]+$", "match": "regex" }, { "description": "report.txt has a DISK_GB line", "command": "grep -E '^DISK_GB=[0-9]+$' /srv/hardware-lab/report.txt", "expected_output": "^DISK_GB=[0-9]+$", "match": "regex" } ] }, "default_namespace": "default", "teardown_commands": [ { "command": "rm -rf /srv/hardware-lab" } ] }