Is it bad practice for folder name to contain dot (.)? How about file name with multiple dots?

As far as I know there is no issues with naming folders and files with a single or multiple dots.

Ubuntu generally does not use the dot and three characters (such as .txt) to identify the file type. So this has no special meaning in the Ubuntu context. This is useful when sharing files with Windows. Ubuntu uses Magic Numbers in the first few bytes of the file to identify the file type. However, Nautilus. ignores the magic numbers if the dot and three characters extension is available to identify the file type. This setting can be changed. See Force nautilus to ignore extensions

In Ubuntu, starting a file or folder names with a dot, such as .experiment_L0.5, makes the file or folder hidden. You can toggle the display of hidden files by pressing Ctrl+H in Nautilus. In Windows a file name starting with a . is not hidden. So if you transfer a hidden file named .experiment_L0.5 into a Windows system it will be plainly visible.

In Ubuntu a file name can end with a dot as it has no special meaning placed at the end. However, in Windows a dot separates the file name and extension, and a file name ending with a dot but no extension is not allowed. When I tried to create such a file in Windows I got a file with just the name, no dot, no extension.

Reference: Wiki on Filenames

Hope this helps.


The short answer

  • Windows does not allow the following characters: <>:"/\|?* (source)
  • More characters that are discouraged are: space and dot . (source)
    • 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 CON, PRN, AUX, CLOCK$, NUL COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9 LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9. (source)
  • The only characters not allowed in Unix file systems I know are / and null (the null byte, \0).
  • 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
  • directory
  • device file (block or character device)
  • ...

In fact, you can also open directories with an editor:

vim /home

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 .txt or .html (both are text files).

Related

  • Why was '.' chosen to represent the current directory and '..' for parent directory?
  • What are inodes good for?
  • A Non-Technical Look Inside the EXT2 File System

For completeness' sake, the names which consist only of a single dot . or two dots .. are special:

  • . refers to the current directory
  • .. refers to the parent directory

Those entries are added automatically and always exist, so you can't have a file named . or ...