forbidden characters in Windows and Linux filenames

Forbidden Characters in Windows & Linux Directory Names

Windows and Linux systems allow you to create and name files and directories as per your requirements but certain characters cannot be used to name directories and files. In this article, we will learn about the forbidden characters in Windows and Linux directory names.

Forbidden Characters in Windows & Linux Directory Names

Some characters are printable ASCII characters while some are non-printable characters. Here are the printable characters that are not supported for filenames and directory names.


 / (forward slash)


 < (less than)
  > (greater than)
  : (colon - sometimes works, but is actually NTFS Alternate Data Streams)
  " (double quote)
  / (forward slash)
  \ (backslash)
  | (vertical bar or pipe)
  ? (question mark)
  * (asterisk)

Here are the non printable characters that cannot be used as filenames or directory names.


  0 (NULL byte)

  0-31 (ASCII control characters)

In addition to above characters, there are also certain reserved filenames that cannot be used in Windows, with or without any extension.

  COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9
  LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9

Also remember that Windows does not distinguish between upper case and lower case characters when it comes to filenames and directory names so if you try to name one file as a.txt and the other file in same directory as A.txt it will not allow you to do so.

Lastly, you should also note that in Windows, filenames and directory names cannot end with whitespace characters.

In this article, we have learnt about the forbidden characters for filenames and directory names in Windows and Linux.

Also read:

MySQL Date Format DD/MM/YYYY in SELECT query
How to Fix MySQL Error 1153
How to Create Temporary Table from SELECT query
How to Select Multiple Columns in Python Pandas
How to Sort Python List By Multiple Elements

Leave a Reply

Your email address will not be published. Required fields are marked *