Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi I am looking for a character in Unix and Windows filesystems that is not allowed in file and directory names and I was wondering if there is such a character (I have noticed that * and % are allowed)?

share|improve this question
Please change either the title or the question so that they are both about the same thing. – John Gardeniers Mar 2 '11 at 11:22
thanks. I have changed the question – Zubair Mar 2 '11 at 12:16
up vote 7 down vote accepted

There is no such thing as a "Unix" filesystem. Nor a "Windows" filesystem come to that. Do you mean NTFS, FAT16, FAT32, ext2, ext3, ext4, etc. Each have their own limitations on valid characters in names.

Also, your question title and question refer to two totally different concepts? Do you want to know about the subset of legal characters, or do you want to know what wildcard characters can be used in both systems? states "all bytes except NULL and '/'" are allowed in filenames. describes the generic case for valid filenames "regardless of the filesystem". In particular, the following characters are reserved < > : " / \ | ? *

Windows also places restrictions on not using device names for files: CON, PRN, AUX, NUL, COM1, COM2, COM3, etc.

Most commands in Windows and Unix based operating systems accept * as a wildcard. Windows accepts % as a single char wildcards, whereas shells for Unix systems use ? as single char wildcard.

share|improve this answer
Technically, the device name restriction is just in the Win32 subsystem. You can create files containing those strings using POSIX on Windows, like in Cygwin. – mfinni Mar 2 '11 at 14:54
@mfinni: 1) Technically it's the Win32 API, not the subsystem. One can use \\?\C:\nul style filenames from within Win32 to bypass this. 2) Cygwin is Win32, it doesn't use the POSIX subsystem (which consumer versions of Windows do not come with), just a runtime library (cygwin1.dll). – grawity Mar 3 '11 at 14:34
Ooh, good points. – mfinni Mar 3 '11 at 14:46

Most filesystems are fairly permissive: for example, all NTFS, extN, btrfs, XFS and ReiserFS allow everything except 1) the null byte and 2) the slash /.

The operating system may have its own restrictions. In particular, the Win320 API disallows * ? as wildcards, \ / as path separators, : as stream separator, and < > | " for no good reason1. Also disallowed are ASCII control characters (the 0x00-0x1F range).

In Unix, wildcard expansion is done by the shell and by the glob() function. In Windows, it's the job of the filesystem driver, which is why * and ? cannot be used in file names.

0 I have no information about the POSIX and OS/2 APIs offered by Windows.

1 They are special in the command line shell (cmd.exe), but it surely could (and in fact does) handle escaping like Unix shells do.

share|improve this answer

It really depends on the filesystem, but most of the Unix filesystems allow any byte except NULL and /. NTFS allows all except NULL and \ / : * ? " < > |.

There is an extremely helpful comparison chart on Wikipedia:

That said, almost all shells recognize * as a wildcard first and a character in a filename only when escaped. Why wouldn't use use *?

share|improve this answer

* should work as a wildcard in both, but it's the shell or the invoked command that expands these things, rather than the filesystem itself. Bash, for instance will expand * to a space separated list of files in the current folder.

I don't think either filesystem expressly forbids any character. It's quite possible to create filenames on ext2 or NTFS with names like *&(. Windows GUI might not let you, but you can do it in Cygwin, since the underlying filesystem allows for it.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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