Why are filenames that start with a dot hidden? Can I hide files without using a dot as their first character?

According to Wikipedia,

The notion that filenames preceded by a . should be hidden is the result of a software bug in the early days of Unix. When the special . and .. directory entries were added to the filesystem, it was decided that the ls command should not display them. However, the program was mistakenly written to exclude any file whose name started with a . character, rather than the exact names . or ...

...so it started off as a bug, and then it was embraced as a feature (for the record, . is a link to the current directory and .. is a link to the directory above it, but I'm sure you know that already). Since this method of hiding files actually is good enough most of the time, I suppose nobody ever bothered to implement Windows-style file hiding.

There's also the fact that implementing different behaviour would produce an even greater amount of fragmentation to the *nix world, which is the last thing anyone wants.

There is another method for hiding files that doesn't involve renaming them, but it only works for GUI file managers (and it's not universal amongst those -- the major Linux ones use it, but I don't think OSX's Finder does, and the more niche Linux file managers are less likely to support this behaviour): you can create a file called .hidden, and put the filenames you want to hide inside it, one per line. ls and shell globs won't respect this, but it might be useful to you, still.


Files starting with a dot are ignored by default by the command "ls", which has more or less the same effect of "hidden" files but is not the same (other commands may choose to do the same or not). Files starting with a dot are not "hidden" because "hidden" is not one of their attributes. Unlike in DOS/Windows, "hidden" is not an attribute in Unix. There are many attributes in Unix ("man chattr" will tell you all of them) but hidden is not one of them.

The reason why dot-files are ignored by "ls" is actually quite funny / embarassing. It was not a design decision but the result of a software bug in the early days of Unix. When the special . and .. directory entries were added to the filesystem, it was decided that the ls command should not display them becasue they were getting in the way. However, the program was hastily written to exclude any file whose name started with a . character, rather than the exact names "." or "..". And it created a precedent that has been followed since then in Unix. Funnily enough, when the Unix guys moved on to create Plan 9 they did not put dot-files in it on purpose.