Under Linux and other Unix-related systems, there are only two characters that cannot appear in the name of a file or directory, and those are NUL '\0' and slash '/' .
Do not use the following reserved names for the name of a file: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9.
Null characters can be used. This character is used to terminate segments of text. Spaces are permitted, although they are best avoided because they can be incompatible with legacy software. File names can only use alphanumeric characters, underscores, hyphens and periods.
There are almost no restrictions - apart from '/'
and '\0'
, you're allowed to use anything. However, some people think it's not a good idea to allow this much flexibility.
An empty string is the only truly invalid path name on Linux, which may work for you if you need only one invalid name. You could also use a string like "///foo
", which would not be a canonical path name, although it could refer to a file ("/foo
"). Another possibility would be something like "/dev/null/foo
", since /dev/null
has a POSIX-defined non-directory meaning. If you only need strings that could not refer to a regular file you could use "/
" or ".
", since those are always directories.
Technically it's not invalid but files with dash(-) at the beginning of their name will put you in a lot of troubles. It's because it has conflicts with command arguments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With