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...
IT & Cybersecurity Package Join Premium for Full Access