![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to flushes file system buffers in the Linux operating system?
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