In Windows and Linux operating systems, the naming rules for directory names and filenames differ, particularly regarding prohibited characters. Below is a detailed explanation of the forbidden characters in each system:
Windows
In Windows systems, filenames or directory names are prohibited from using the following characters:
<(less than)>(greater than):(colon)"(double quote)/(forward slash)\(backslash)|(vertical bar)?(question mark)*(asterisk)
Additionally, Windows filenames cannot end with a space or a period.
Linux
Linux systems have relatively lenient restrictions for filenames and directory names, with only two characters prohibited:
/(forward slash): as it is the directory separator.\0(null character): as it is the string terminator.
Linux filenames can include spaces, periods, and even special characters prohibited in Windows. However, for usability and compatibility reasons, it is generally recommended to avoid using overly complex special characters in filenames.
Example
For example, if you attempt to create a file named report:data.txt in Windows, the system will prohibit this operation because the filename contains the : character. In Linux, you can create a file named my:file.txt, as the system will not block the creation of filenames containing special characters unless you manually include / or \0.
In summary, it is important to consider the operating system restrictions and best practices when naming files or directories to ensure compatibility with the file system and ease of use for users.