The short answer
- Windows does not allow the following characters:
- More characters that are discouraged are: space
- Command line tools are harder to use when you have spaces in names (harder, not impossible)
- Dots are used in RegEx (e.g. when you want to use
grep). A leading dot makes a file hidden by convention in Linux. In Windows, dots are used in the file extension, which is used for file type detection.
- Windows also will not allow filenames
- The only characters not allowed in Unix file systems I know are
/ and null (the null byte,
- See also: File system limits (I don't know to which Windows you want to be compatible).
The long answer
Technical background: File System
Ubuntu makes use of the
ext4 file system. A file system tracks where files are stored on the underlying storage (disk or SSD or whatever), permissions in the form of owner/group/other can read/write/execute, timestamps, name.
The file system structures the available storage. The first block is called the "superblock". This block is used to mount a file system. As far as I know, every modern file system divides it's space in blocks. I think (and I'm not too sure about it) that most file systems also have a fixed block size, though the block size can be configured when the file system is created. ext4 (and also ext2 and ext3) make use of so called "inodes" for files and directories. Those inodes contain pointers to other blocks (that might also be inodes or be "data blocks"). And the "first" inode of a file contains all of the information I mentioned above.
One other information is the "type" of the file. "Type" can be:
- regular file
- device file (block or character device)
In fact, you can also open directories with an editor:
As the directory does not contain the full path, but only the names of the content I don't see a reason why files can not contain a
/. I guess it might be convenience. (Does anybody know why
/ is not allowed?)
However, things are different for other file systems. The FAT16 and FAT32 used a so called "file allocation table". This means there is a table that contains all files that are stored on your file, at which "cluster" they start and at which cluster they end as a singly linked list.
The important thing I wanted to tell you is that disallowed characters might also depend on the file system.
Technical background: File Types
- Windows uses file extensions to detect file types
- Linux uses "Magic Bytes" to detect file types. Magic Bytes are part of the content of the file and hence completely independent of the name. These bytes are part of the specification of the file type (see png specification as an example). It also uses the filename extensions for files with the same magic bytes such as
.html (both are text files).