LFCS Essential Commands Practice Question
A junior administrator needs to create a new empty file named report.txt in the current working directory. They want to ensure that if the file already exists, its contents are not altered. Which command should they run?
⚠ Common exam trap
The trap here is assuming that any command that creates a file will also safely leave existing content untouched, when in fact redirection operators truncate files by default.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
touch report.txt
The touch command is designed to create empty files or update timestamps without modifying existing content. Redirection methods like echo > or cat > would truncate the file if it already exists, risking data loss. mkdir creates a directory, not a file. Therefore, touch is the correct choice for safely creating an empty file.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
mkdir report.txt
Why it's wrong here
mkdir creates a directory, not a regular file. Using it with report.txt would create a directory named report.txt, which is not what the administrator needs. This would cause confusion and fail to produce the intended empty file.
- ✗
echo > report.txt
Why it's wrong here
Running echo with output redirection writes an empty line into report.txt, truncating any existing content. This violates the requirement to not alter the file if it already exists. Also, echo alone outputs a newline, so the file would contain a newline character, not truly be empty.
- ✗
cat > report.txt
Why it's wrong here
The cat command with output redirection will wait for standard input and overwrite report.txt, destroying any existing data. It is used for writing content interactively, not for safely creating an empty file. If the file exists, its contents are lost, which is unsafe here.
- ✓
touch report.txt
Why this is correct
The touch command updates the access and modification timestamps of report.txt, and if the file does not exist, it creates an empty file. It does not modify the file's contents if it already exists, so it safely meets the requirement without risking data loss.
Go deeper
Related to this question
About these practice questions
One of 406 original LFCS practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Linux Foundation exam blueprint
This LFCS practice question is part of Courseiva's free Linux Foundation certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the LFCS exam.