Difficulty: Easy
Correct Answer: touch
Explanation:
Introduction / Context:
File timestamps (atime for last access and mtime for last modification) are frequently used by backup systems, build tools, and compliance workflows. Sometimes you need to update these times without editing the file's data, or create an empty file if it does not already exist. Unix provides a simple command for both tasks.
Given Data / Assumptions:
Concept / Approach:
The touch command updates atime and mtime on existing files and creates zero-length files if they do not exist. Options like -a, -m, -t, and -r provide fine-grained control over which times are changed and which reference is used. This is preferred over modifying content merely to bump timestamps, which can corrupt data or interfere with checksums.
Step-by-Step Solution:
Verification / Alternative check:
Run stat file.txt (or ls -l --time-style=full-iso) before and after touch to confirm atime/mtime changes without altering file size or checksum.
Why Other Options Are Wrong:
Common Pitfalls:
Misunderstanding filesystem mount options like noatime/relatime that affect access time behavior, or using incorrect -t format leading to failed updates.
Final Answer:
touch
Discussion & Comments