Which style of naming files and folders is the most compatible within the Linux ecosystem and thus recommended to be consistently applied?

  • @Gilles has provided a very good answer. Should we keep it as is, thus not editing the question to limit its scope?
    – orschiro
    Jul 11, 2015 at 7:44
  • I won't vote to delete it, but it should still stay closed. this won't be auto deleted.
    – user3
    Jul 12, 2015 at 11:36

1 Answer 1


The one absolute rule is that you can't use a slash / in a file name. That's the directory separator and it can't be escaped. Apart from that, any character is allowed on Linux (except when accessing media or network resources shared with other filesystems), but a number of characters can cause trouble.

  • Don't start a file name with - (dash/hyphen). Commands may interpret it as an option.
  • Don't use an initial ~ (tilde) because that means “home directory” in many applications.
  • If you're going to exchange files with Windows users, or to put files on removable media, avoid characters that Windows doesn't support: \/?:*"><|
  • Don't use nonprintable characters (e.g. control characters), tabs or newlines. You won't even be able to type them in many interfaces.
  • Some badly written shell scripts may choke on spaces as well as \*?[] because they're wildcards. In addition, some applications that can act on multiple files at once interpret these characters as wildcards.
  • If you're going to exchange files with older computers or with people who speak a different language, especially one written in a non-Latin alphabet, they may use a different character encoding. The ASCII characters are guaranteed to be available everywhere and encoded in the same way.
  • Many applications use the file extension, to figure out what files they support and how they open it. The system also uses the extension to determine what application to open the file with. So leave extensions in place. The extension is the part after the last dot, e.g. txt in myfile.txt; sometimes there are multiple extensions, e.g. myfile.txt.gz for a compressed (.gz) text (.txt) file.
  • File names beginning with . are hidden by default in Files, in the output of the ls command and in many other file browsers.
  • Linux is case-sensitive: myfile is not related to Myfile. Traditionally file names are in lowercase, largely because that makes them easier to type. In the old days, systems usually sorted uppercase letters before lowercase letters, so there's a tradition of starting a file name with a capital letter to make it come first in directory listings, but modern systems often sort names case-insensitively. Sticking to lowercase avoids confusion and is easier to type.

If you'd rather not remember all these complex cases, here are just two simple rules:

  • Maximum safety: stick to letters az and digits 09, plus - to separate words, and .extension at the end of the file name. For example: my-file.txt
  • More readable: use letters and digits in English or in your own script, plus space or - to separate words, and .extension at the end of the file name. For example: Jörgs Datei.txt

Final tip: use the YYYYMMDD format (year-month-day, with 4 digits for the year and a leading zero in the month and day number) for dates, e.g. 20150622-report.txt. That way, sorting the file name gives you chronological order.

  • +1 for the date recommendation. It might be worth mentioning that starting with a . will make it a hidden file in both ls and many (most?) file browsers.
    – user3
    Jul 8, 2015 at 9:53

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