The Linux Newbie Guide  ⇒    Fundamentals     Advanced     Supplement   Command Index   ENG⇒中
All rights reserved, please indicate the source when citing
  

sync - Synchronize Memory and Disk




The sync command is short for synchronize. Its function is to force the data from the buffer memory to be written to the hard disk. It is often used in conjunction with system shutdown.

In Linux, data is typically stored in RAM and written to the hard disk when there is an opportunity, which can improve system performance and avoid frequent disk reads and writes. However, because it is not known when the system will have an opportunity to write to the disk, if the system suddenly shuts down (such as a power outage), data in RAM may be lost before it can be written to the disk.

The sync command is used to force data from RAM to be written to the disk, ensuring that data is not lost. Therefore, it is generally recommended to execute the sync command before shutting down the system.

In addition to shutting down the system, the sync command can also be used in the following situations:

For examples and detailed usage, please refer to the provided link.