Are there any invalid linux filenames?

izb picture izb · Aug 21, 2009 · Viewed 36.3k times · Source

If I wanted to create a string which is guaranteed not to represent a filename, I could put one of the following characters in it on Windows:

\ / : * ? | < >

e.g.

this-is-a-filename.png

?this-is-not.png

Is there any way to identify a string as 'not possibly a file' on Linux?

Answer

Vinay Sajip picture Vinay Sajip · Aug 21, 2009

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.