On this page
reference
sync
sync flushes cached writes to persistent storage.
sync [options] [file...]
$ sync
When a program writes to a file, the data does not always reach the physical device immediately — for speed, the system holds recent writes in memory and writes them out a little later. sync forces that pending data out now, so that what is on the device matches what programs have written.
It is the command to run before doing something that should not lose recent writes — before powering off by hand, or before removing storage.
Options
With no argument, sync flushes everything. The options narrow it:
| Option | Effect |
|---|---|
file... |
Flush only the given files, rather than everything. |
-d, --data |
For the given files, flush only the file data, not metadata that does not need it. |
-f, --file-system |
Flush the entire file system that contains each given file. |
Exit status
sync returns 0, or 1 if a named file could not be reached.
See also
Peios Learn
Built with Trail