sync: man page

A lot of people use sync.

Do you know what it does!

Did you know that sometimes sync takes time and isn’t immediately completed.

SYNC(1)                                               SYNC(1)


       sync - Synchronize cached writes to persistent storage


       sync [OPTION] [FILE]...


       Synchronize cached writes to persistent storage

       If one or more files are specified, sync only them, or their
       containing file systems.

       -d, --data
              sync only file data, no unneeded metadata

       -f, --file-system
              sync the file systems that contain the files

       --help display this help and exit

              output version information and exit


       Persistence guarantees vary per system.  See the system calls below
       for more details.


       Written by Jim Meyering and Giuseppe Scrivano.


       GNU coreutils online help: <>
       Report sync translation bugs to


       Copyright © 2017 Free Software Foundation, Inc.  License GPLv3+: GNU
       GPL version 3 or later <>.
       This is free software: you are free to change and redistribute it.
       There is NO WARRANTY, to the extent permitted by law.


       fdatasync(2), fsync(2), sync(2), syncfs(2)

       Full documentation at: <>
       or available locally via: info '(coreutils) sync invocation'


       This page is part of the coreutils (basic file, shell and text
       manipulation utilities) project.  Information about the project can
       be found at ⟨⟩.  If you have a
       bug report for this manual page, see
       ⟨⟩.  This page was obtained
       from the tarball coreutils-8.29.tar.xz fetched from
       ⟨⟩ on 2018-04-30.  If you discover
       any rendering problems in this HTML version of the page, or you
       believe there is a better or more up-to-date source for the page, or
       you have corrections or improvements to the information in this
       COLOPHON (which is not part of the original manual page), send a mail

GNU coreutils 8.29              December 2017                        SYNC(1)

sync(2) – Linux man page


sync, syncfs – commit buffer cache to disk


#include <unistd.h>

void sync(void);

int syncfs(int fd);

Feature Test Macro Requirements for glibc (see feature_test_macros(7)):



sync() causes all buffered modifications to file metadata and data to be written to the underlying file systems.

syncfs() is like sync(), but synchronizes just the file system containing file referred to by the open file descriptor fd.

Return Value

syncfs() returns 0 on success; on error, it returns -1 and sets errno to indicate the error.


sync() is always successful.

syncfs() can fail for at least the following reason:

EBADFfd is not a valid file descriptor.


syncfs() first appeared in Linux 2.6.39; library support was added to glibc in version 2.14.

Conforming To

sync(): SVr4, 4.3BSD, POSIX.1-2001.

syncfs() is Linux-specific.


Since glibc 2.2.2 the Linux prototype for sync() is as listed above, following the various standards. In libc4, libc5, and glibc up to 2.2.1 it was “int sync(void)”, and sync() always returned 0.


According to the standard specification (e.g., POSIX.1-2001), sync() schedules the writes, but may return before the actual writing is done. However, since version 1.3.20 Linux does actually wait. (This still does not guarantee data integrity: modern disks have large caches.)

See Also

bdflush(2), fdatasync(2), fsync(2), sync(8), update(8)

Referenced By

apmd(8), clubufflush(8), ctrlaltdel(8), fclose(3), fflush(3), guestfish(1), guestfs(3), nfs(5),reboot(2), sync(1), sync_file_range(2), xfs_quota(8), zshmodules(1)