Software & Apps Linux 35 35 people found this article helpful A Step-By-Step Guide to Using the Linux 'sync' Command Use the 'sync' command if you anticipate a power outage by Juergen Haas Writer Former Lifewire writer Juergen Haas is a software developer, data scientist, and a fan of the Linux operating system. our editorial process Juergen Haas Updated on September 27, 2020 Linux Switching from Windows Tweet Share Email The sync command for Linux 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 the hard disk. This approach is fine until there is a computer crash. When a Linux machine experiences an unplanned shutdown, all the data that was held in memory is lost, or the file system is corrupted. The sync command forces everything in temporary memory storage to write to a persistent file storage—like a disk—so none of the data is lost. When to Use It Usually, computers shut down in an organized manner. If the computer halts or the processor stops in an unusual manner—such as when you're debugging kernel code or in the event of a possible power outage—the sync command forces an immediate transfer of the data 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. Syntax The command takes the following form: sync [option] [file] Options for this command include: --help displays any available help and then exits--version displays version information and exits--data (or -d) syncs only file data without the metadata that supports it--file-system (or -f) also syncs the file systems that contain the referenced files Considerations It's not common to manually invoke sync, and when it's run, it doesn't return results to the standard output. Most often, people run this command before some other command that could destabilize the Linux kernel—or if you believe that something bad is about to happen, such as running out of battery power, and you don't have time to execute a full system shutdown. When you halt or restart the system, the operating system automatically syncs data in memory with persistent storage, as needed.