Difficulty: Easy
Correct Answer: sync
Explanation:
Introduction / Context:
Modern UNIX/Linux systems aggressively cache disk writes in memory to improve performance. At times, an administrator needs to force these buffered writes to be committed to persistent storage, for example before removing power or unmounting a filesystem. The classic utility for this task is the sync command.
Given Data / Assumptions:
Concept / Approach:
The kernel defers writes to batch I/O. The sync command asks the kernel to write all dirty filesystem caches (metadata and data) to disk devices. It does not guarantee hardware cache flush on every device, but it ensures the OS-level buffers are issued to storage. Running sync multiple times is harmless and sometimes used out of caution.
Step-by-Step Solution:
Verification / Alternative check:
Use tools like mount or lsof to ensure no open files before unmount. Review system logs (e.g., dmesg) to see any I/O errors. Some filesystems expose statistics (e.g., /proc/meminfo Dirty pages) that decrease after sync completes.
Why Other Options Are Wrong:
save: Not a standard UNIX command for flushing buffers. edbuff: Not a valid core utility. flush: Not a portable command for this purpose. None of the above: Incorrect because sync is the correct command.
Common Pitfalls:
Assuming sync powers off disks; it only requests write-out. Believing sync fixes hardware cache policies; device write caches may still hold data unless the kernel issues barriers. Always pair sync with proper unmount/eject procedures.
Final Answer:
sync
Discussion & Comments