When I do 'ls -l', I might get something like this:

-rw-r--r-- 1 root root 209 Mar 30 17:41 fname

The first field is the -, which means this is a file.

If it was a directory and not a file, the first field would be a d.

Why did the creators of Unix decide to use a d for directory, which is clear and intuitive, yet use a - for a file? Why not use f for a file?

Really interesting responses. Lots of different ideas, and they all make sense, even if some seem more inadvertently true than implemented for that reason and/or are documented as that being the reason.

  • 1
    Directory is a file, just a special type. So it makes sense to indicate that's a special type of file with d, but it's pointless for regular file. See askubuntu.com/q/1073802/295286 and askubuntu.com/a/1073805/295286 There's a few historical notes there on the topic. Sep 22, 2018 at 19:49
  • Let me know if you have any questions or any parts of the answers need clarification. Sep 22, 2018 at 19:51
  • 2
    If you assume that regular files are the most common thing to be found in a directory listing, then representing them by a small character like - makes the rarer file types (everything else) stand out.
    – user41515
    Sep 22, 2018 at 19:57
  • Understanding UNIX permissions and file types might be relevant here. Sep 22, 2018 at 20:21
  • There's this similar question, but the wording of this question asks "why" and that's much harder to answer.
    – Jeff Schaller
    Sep 23, 2018 at 1:07

1 Answer 1


Historically, one of the big design decisions in Unix was to consider everything as a file.¹ This transpires in early ls and stat manpages; for example, in V3 (February 1973), the stat manpage (which describes the mode used by ls) says that

The mode is a six-character string whose characters mean the following:

  1. s: file is small (smaller than 4096 bytes)
    l: file is large
  2. d: file is a directory
    x: file is executable
    u: set user ID on execution
    -: none of the above


In V4 (October 1973) the mode starts to resemble what we have today; the ls manpage says

The mode printed under the -l option contains 10 characters which are interpreted as follows:

the first character is
d if the entry is a directory;
b if the entry is a block-type special file;
c if the entry is a character-type special file;
- if the entry is a plain file.

The next 9 characters are interpreted as three sets of three bits each.

So it seems the creators of Unix really thought that a plain file is “just” the default, nothing special, so it doesn’t deserve a character — everything is a file, and only files which aren’t plain files need additional description. One could think of - as signaling the absence of “specialness”.

¹ Strictly speaking, the design decision was to make everything accessible through the file system, not to consider everything as a file; but as a result, everything had to be made available as some sort of file, and this required being able to distinguish different types of files. See section 3 of The UNIX Time-Sharing System.

  • wait a minute tho....if a plain text file is the expected default, then shouldn't Unix say, "Hey guys, this is just the default thing we like, so give it a hearty "YES"!'. But the dash seems to represent a 'no'. Like 'r-x' means 'no' for 'write'. The dash's meaning is going back and forth as a Yes and a No, so to speak (at least if you look at it this way...) Sep 22, 2018 at 20:17
  • I take the dash as meaning “default”. Files are plain files (not plain text files, just plain files, as opposed to directories and special files) by default, unreadable by default (i.e. if they don’t have the read bit set), etc. Sep 22, 2018 at 20:20
  • 4
    @Sergiy bit of a nitpick, the rest of your comment is fine, but no, the MIME type isn’t the header... (How are file types known if not from file suffix?) Sep 22, 2018 at 20:31
  • 2
    @Sergiy, no, there is no header. There are heuristics to try to guess a file’s type but there is no guaranteed header, or magic number, etc. All sorts of fun and games can be had by abusing those guesses. Sep 22, 2018 at 20:34
  • 2
    @Sergiy I know what you’re trying to convey, but in my experience it’s too simplistic and it ends up confusing users. file, and the shared MIME database, apply a sequence of detection tests, some of which look at the first few bytes of a file. But claiming that the first few bytes of a file give an indication of its type gives readers the wrong impression. There is no guaranteed way of determining a file type (unlike Mac OS Classic or PalmOS where each file had a type and creator code). Sep 22, 2018 at 20:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.