Skip to content

sync Command Cheat Sheet

sync synchronizes cached writes to persistent storage. It forces the kernel to write data buffered in memory out to disk.


Synopsis

sync [OPTION] [FILE]...

Basic Usage

Sync Everything

Flushes all file system buffers.

sync
Run this before pulling out a USB drive if you can't unmount it properly.

Sync Specific File

Only sync data related to specific files.

sync big_database.db

Sync File System (-f)

Sync the file system containing the file.

sync -f /mnt/usb/

Notes

  • Shutdown: valid shutdown, reboot, and halt commands automatically run sync.
  • Time: If you copy a massive file and run sync, the command prompt will hang until the write is physically complete.