nerdexam
CompTIACompTIA

XK0-005 · Question #761

XK0-005 Question #761: Real Exam Question with Answer & Explanation

The correct answer is D: mkdir CompTIA_doc && cd CompTIA_doc. {"question_number": 4, "correct_answer": "D", "explanation": "The '&&' operator executes the second command only if the first command exits successfully (exit code 0). Using 'mkdir CompTIA_doc && cd CompTIA_doc' ensures the directory is created before attempting to change into it

System Management

Question

A Linux administrator is creating a directory called CompTIA_doc, and it needs to switch to another location to perform some system-related tasks. Which of the following commands should the administrator use for this task?

Options

  • Amkdir CompTIA_doc & cd CompTIA_doc
  • Bmkdir CompTIA_doc + cd CompTIA_doc
  • Cmkdir CompTIA_doc || cd CompTIA_doc
  • Dmkdir CompTIA_doc && cd CompTIA_doc

Explanation

{"question_number": 4, "correct_answer": "D", "explanation": "The '&&' operator executes the second command only if the first command exits successfully (exit code 0). Using 'mkdir CompTIA_doc && cd CompTIA_doc' ensures the directory is created before attempting to change into it - if mkdir fails (e.g., directory already exists with error), cd is never attempted. A single '&' runs the first command in the background and immediately starts the second, which would fail because the directory may not exist yet. '+' is not a valid shell operator. '||' is a logical OR, running the second command only if the first fails - the opposite of the intended behavior.", "generated_by": "claude-sonnet", "llm_judge_score": 4}

Topics

#File System Commands#Directory Operations#Command Chaining#Shell Operators

Community Discussion

No community discussion yet for this question.

Full XK0-005 PracticeBrowse All XK0-005 Questions