A system administrator needs to update the timestamps of an existing log file, app.log, to match the timestamps of a source file, source.file. A critical requirement is that if app.log does not already exist, the command must not create a new file. Which of the following commands will successfully perform this action?
The correct command is touch -c -r source.file app.log. The -r (--reference) option tells touch to use the timestamps from the specified reference file (source.file) instead of the current time. The -c (--no-create) option prevents touch from creating the file if it does not exist. The other options are incorrect because they either create the file if it's missing or perform an entirely different operation. touch -r source.file app.log would incorrectly create app.log if it didn't exist. touch -d "$(date -r source.file)" app.log also fails the no-create requirement. cp -p source.file app.log is incorrect because it copies the content of source.file to app.log, rather than just updating the timestamps of the existing app.log file.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the `-c` option in the `touch` command do?
Open an interactive chat with Bash
What is the purpose of the `-r` option in the `touch` command?
Open an interactive chat with Bash
Why does `touch -r source.file app.log` create a new file if `app.log` does not exist?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Services and User Management
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .