A Step-By-Step Guide to Using the Linux Sync Command

Use the Linux Sync command if you anticipate a power outage

Faster download
John Lamb / Getty Images

Managing the Linux operating system isn't particularly clear-cut, but learning the commands that instruct the system to perform basic operations is a big step in the right direction. The Sync command writes any data that is buffered in the computer's memory to disk. 

Why Use the Sync Command

To improve performance, a computer often keeps data in its memory rather than write it to disk because the RAM is much faster than accessing the hard disk.

This is fine until there is a computer crash. When that happens the data that was held in memory is lost, or the file system is corrupted. The Sync command causes everything to be written to disk so none of the data is lost. 

When to Use the Sync Command

Usually, computers are shut down in an organized manner.  If the computer is going to be shut down or the processor stopped in an unusual manner, such as when debugging kernel code or in the event of a possible power outage, the Sync command forces an immediate transfer of the code in memory to disk. Because modern computers have potentially large caches, when you use the sync command, wait until all the LEDs that indicate activity stop blinking before turning off the power on the computer.

Sync Syntax

sync [--help] [--version]  

Options When Using the Sync Command

Options for the Sync Command are:

  • --help displays any available help and then exits
  • --version displays version information and exits
Was this page helpful?