Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

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

I had an exam this week, and one of the questions was (with one correct answer):

The file name can contain the character:

a) \

b) /

c) ?

d) !

I chose c) ? because it looked OK to me. When I came home I tested it on my machine (Ubuntu 14.04) and the file was created successfully. In the ready reckoner the correct answer is marked to be d) !.

I knew that the exam was Windows specific, but on the test paper the platform was not specified.

It's clear that \ and / characters are not supported in a file name, BUT is there any way to force the operating system to allow them?

It would be really cool to proove that even \ and / characters are supported.

share|improve this question
In MS Windows, d) is the correct answer. – choroba Jun 19 '14 at 7:58
@choroba I know, but on Linux ? is correct as well. Also, the platform was not specified. :-) – Ionică Bizău Jun 19 '14 at 8:05
up vote 5 down vote accepted

There are two limiting factors when considering the characters permitted in a file name — restrictions related to the operating system, and restrictions related to the file system. For this question I will assume we are talking about recent versions of Linux and ext4.

Linux only disallows two characters in filenames: /, because it is the path separator, and \0 (ASCII NUL), because it terminates cstrings. In addition to this, the special names . and .. are also reserved by the filesystem for use as navigational hard links.

You can easily demonstrate that the other characters mentioned in your question are allowed:

$ touch '\' '?' '!'
$ ls
!  ?  \
share|improve this answer
Isn't there any way to force the system to accept / as well? I know it's a restriction, but maybe there are workarounds... – Ionică Bizău Jun 19 '14 at 8:08
@IonicăBizău Almost certainly not through conventional methods. You could try using debugfs, but you should expect bad things to happen if you succeed. – Chris Down Jun 19 '14 at 8:21
I don't care about bad things, how can I use debugfs to create a file named foo/bar, for example? – Ionică Bizău Jun 19 '14 at 11:05
@IonicăBizău you can also cheat. Try copying this into a terminal: touch 'foo̸̸ bar' – terdon Jun 19 '14 at 13:08
@terdon That's a good idea, but not perfect. This is perfect: touch 'foo ∕ bar'. So, Chris, you can update your answer and I will mark it! :-) – Ionică Bizău Jun 19 '14 at 15:17

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.