How to flushes file system buffers in the Linux operating system?

LinuxOperating SystemOpen Source

To synchronize cached writes to persistent storage, we use the sync command in the Linux operating system.

The sync command is used to synchronize corresponding file data in volatile memory and persistent storage.

Syntax

The general syntax of the sync command is as follows −

sync [OPTION] [FILE]...

A brief description of options available in the sync command

Sr.No.Option & Description
1-d, --data
Synchronize only file data, no unneeded metadata.
2-f, --file-system
Synchronize the file systems that contain files.
3--help
Displays a help message and then exits.
4--version
It gives info about the version and then exits.

Note - If one or more files are specified, synchronize only them, or their containing file systems.

To synchronize all cached files of the current user in the Linux operating system, we use the sync command with sudo privilege as shown below.

$ sudo sync

The sync command works silently without displaying anything on the terminal.

To synchronize only file data, no unneeded metadata in the Linux operating system, we use -d option with the sync command as shown below

$ sync -d shadow/file.txt

In the above example, a file ‘file.txt’ available in the shadow directory.

To synchronize only file systems that contains the files in the Linux operating system, we use -f or --file-system with the sync command as shown below.

$ sync -f shadow/file.txt

To display the version information of the sync command in the Linux operating system, we use the --version option with the sync command as shown below.

$ sync --version

To check more information about the sync command in the Linux operating system, we use the --help option with the sync command as shown below.

$ sync --help
raja
Published on 01-Jul-2021 14:28:44
Advertisements