Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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 understand that this will likely break and confuse the hell out of my system, but is it possible to name or rename a file so that it has /s in its name (this is needed for a file which needs to go to an equally crazy server - well, sort of, it's more of a crazy workaround)? I am running Ubuntu GNOME 15.10 with GNOME 3.18, and I have tried to do this with most programs, and they either make a folder with the file because they treat what is before the / as the folder and what is after it as the file name, or just give me an error.

Reason:

The specific reason why I need it is because I set up a server which is stubborn and now won't change it's mind about where its config file is. However I accidentally put a / in the name of the file so it believes that the config file rather being in ~/configuration/files/config1.conf is in ~/configuration/files/con/fig1.conf... So you might say that I should just create a folder in files and call it con and then have the config file called fig1.conf, however the server doesn't even currently allow the creation of new directories or anything really... So I think that my only hope is going to be to put the forward slash in the file name for now until it goes out of its lock down mode.

share|improve this question
4  
POSIX forbids "/" and NULL in filenames ;) – Rinzwind Jan 11 at 20:38
1  
Oh and if you want to delete it: use the inode to reference the file – Rinzwind Jan 11 at 20:41
1  
Sounds like a very elaborate approach to avoid learning how to configure your server :/ – Tyler Jan 11 at 22:35
2  
@ParanoidPanda What is this "lock down mode" you speak of? I'm not aware of any such feature on Ubuntu... – Cyle Jan 11 at 22:49
1  
Next thing you'll be trying to put in a file name is a real live bamboo shoot ;) – user2121 Jan 11 at 22:59
up vote 7 down vote accepted

Is it possible to name or rename a file so that it has /s in its name [...]?

No, it's not, for obvious reasons.

E.g. consider you have a directory containing:

  • a directory named "foo" containing a file named "bar"
  • a file named "foo/bar"
/path/to/foo/bar # file named "bar" in the directory named "foo"
/path/to/foo/bar # file named "foo/bar"

Referencing either of the two would be ambiguous.

If you're curious as to where the limitation is imposed, that's at the kernel level, in order to comply with the filesystem's specifications.

In general, any character can be used in a filename aside from / (unicode 002f) and \0 (unicode 0000), and filenames such as . and .. are disallowed as well.

share|improve this answer
    
And what would happen if I got a file with a forward slash in the name from another filesystem and put it onto my machine? – Paranoid Panda Jan 11 at 18:58
    
And is there now way at all of bypassing this and putting a file there? I mean, what if I loaded if off a LiveUSB onto the machine while the machine was not on but the disk mounted? – Paranoid Panda Jan 11 at 19:02
    
@ParanoidPanda superuser.com/q/603792/427197 – kos Jan 11 at 19:03
4  
@ParanoidPanda that would make the filesystem incomptatible with POSIX ;-) – Rinzwind Jan 11 at 20:15
1  
@ParanoidPanda If the file does indeed have a / in its name on the underlying file system I can imagine one of two possible outcomes. Either a programmer was paranoid about corrupted data coming back from the file system and reported this as an error. Or the / would be visible all the way through to user mode. However that would only make the file name visible. Any attempt to stat the file to get more information or open it would cause the kernel to parse the file name and interpret the / as a directory separator. Hence you would not be able to access the file, even if you can see it – kasperd Jan 11 at 22:54

It CAN be done, not easily, not well, and not recommended (it creates problems when trying to remove the file.

Simply use a unicode substitute. It's better explained at linuxanswers.com.

bash shell example using the unicode "fractional slash" U+2044

bash# >test$'\xe2\x88\x95'file
bash# ls --show-control-chars
test∕file
bash# ls
test???file

I don't know if however the server can then access the file, but Ubuntu can. You may have to alias it at the server end, if possible. (Haven't had to touch a Windows installation since the days of Windows 95).

share|improve this answer
1  
Could provide the unicode substitute to use? – Paranoid Panda Jan 11 at 21:14
2  
This won't actually help the OP, since their "server" is expecting an actual ASCII slash, not a Unicode character that just happens to look like a slash. – Ilmari Karonen Jan 12 at 0:59

Your Answer

 
discard

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.