Linux command
sync 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Flush all file system buffers
sync
Synchronize a specific file
sync [path/to/file]
Synchronize data only
sync -d [path/to/file]
Synchronize file systems
sync -f [path/to/file]
说明
sync flushes file system buffers, forcing changed blocks (dirty pages) to be written to disk. This ensures data currently held in memory is persisted to storage. Linux buffers write operations in memory for performance, bundling and reordering disk I/O. While efficient, this means an unexpected crash or power loss could result in data loss. sync forces the kernel to write buffered data to disk, ensuring integrity. When called without arguments, sync flushes all buffers system-wide. With FILE arguments, only those files are synchronized.
参数
- -d, --data
- Sync only file data, skip unnecessary metadata
- -f, --file-system
- Sync the file systems containing the specified files
- --help
- Display help and exit
- --version
- Output version information and exit
FAQ
What is the sync command used for?
sync flushes file system buffers, forcing changed blocks (dirty pages) to be written to disk. This ensures data currently held in memory is persisted to storage. Linux buffers write operations in memory for performance, bundling and reordering disk I/O. While efficient, this means an unexpected crash or power loss could result in data loss. sync forces the kernel to write buffered data to disk, ensuring integrity. When called without arguments, sync flushes all buffers system-wide. With FILE arguments, only those files are synchronized.
How do I run a basic sync example?
Run `sync` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -d, --data do in sync?
Sync only file data, skip unnecessary metadata