1

When I do sync as a regular user, does this flush all the buffers belonging to other users including root or just my own? man doesn't provide this info.

I'm asking about Debian 9 in particular, but more general answers on Linux and Unix are welcome.

  • Related questions are https://unix.stackexchange.com/questions/215356/ , https://unix.stackexchange.com/questions/286762/ , https://unix.stackexchange.com/questions/28554/ , and of course https://unix.stackexchange.com/questions/5260/ . – JdeBP Sep 12 '18 at 21:50

1 Answers1

5

The sync command uses the sync system call.

The manual of the sync system call says:

sync() causes all pending modifications to filesystem metadata and cached file data to be written to the underlying filesystems.

So sync will flush all the buffers. The term "belonging to users" doesn't apply to the buffers, the buffers belong to files and to file system metadata, not to users. It is possible that multiple users modify the same file, and it makes no sense for the file system and buffer sub system to track the changes to a specific user.

RalfFriedl
  • 8,981
  • Thanks. Isn't this a security risk that someone will keep draining the IO? –  Sep 12 '18 at 17:55
  • 2
    @Tomasz any user who has sufficient access to be able to run sync is likely to also have sufficient access to cause more I/O than sync does — e.g. grep -r hello / — or wreak other forms of havoc. sync won’t compromise confidentiality so there’s no risk on that side of things. – Stephen Kitt Sep 12 '18 at 18:03