0

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.

4

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.

| improve this answer | |
  • Thanks. Isn't this a security risk that someone will keep draining the IO? – user147505 Sep 12 '18 at 17:55
  • 1
    @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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy