In GNU tar, the manpage says:

The default is --sort=none, which stores archive members in the same order as returned by the operating system.

But what does the operating system return? Especially, I am interested, if it is guaranteed that when I pass the tar entries as command line arguments in

tar -cf file.tar a b c

that the order of a, b and c is preserved.

  • The order of the entries in the directories depend on the filesystem and not on the operating system.
    – schily
    Mar 21, 2019 at 13:42
  • To be fair, at least on Linux, the filesystem is part of the operating system.
    – flowit
    Mar 23, 2019 at 12:56

1 Answer 1


The sorting order specified with --sort only affects the sorting of the files and subdirectories of directories specified on the command line. It does not affect the order in which the paths on the command line are given.

In your case, the command

tar -cf file.tar a b c

will archive a before b, and then c last, regardless of the --sort order specified. If any of these are directories, then using --sort will affect the order in which the files and subdirectories are added from these directories, but it will not affect the order of a, b and c.

The order in which the operating system returns entries is the same as the one they appear in when using ls -f. This order is the order in which the directory node stores the entries and may depend on many factors, such as in which order files have been added and deleted (it is dependent on the filesystem implementation).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .