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


Sometimes it makes practical sense for a folder name to contain a dot (.). For example, you are storing data for an experiment conducted at L=0.5. So the folder might be named:


A similar issue may arise for file names. For example:


Working in Ubuntu, is this bad practice? How about if sharing these directories with a Windows user?



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.


For completeness' sake, the names which contain 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 ...


The short answer

  • Windows does not allow the following characters: <,>,:,",/,\,|,?,* (source)
  • More characters that are discouraged are: space and . (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 invisible by convention in Linux and in Windows, dots are used for file type detection. Which leads to the next point.
  • Windows does also have problems with extensions: 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).
  • 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 file system¹, 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 endings 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).


1: This might be different today. I think the disks provide an abstraction layer for the operating system. In the beginnings of OS they had to store information like sector, track and plate:

source: commons.wikimedia.org/wiki/File:Cylinder_Head_Sector.svg

Source: https://commons.wikimedia.org/wiki/File:Cylinder_Head_Sector.svg



This do not matter, not in linux nor in windows.

It's a common practice to have folder named "program.d" - to save configuration and stuff for a program (look in /etc directory)


File naming is very flexible in Unix, Linux file-systems. The only file-name you can't have is a null character or the one containing a / in its name. But it surely would be a good practice to avoid using the characters that are forbidden/reserved in other systems from name-portability point of view; like you shouldn't use any of " * : < > ? \ / | characters (restricted by NTFS) in your file-name if you want to access the file in a Windows system.

And about using a . (period) in file-name, I think it should be fine as it doesn't seem to be a "reserved" character in any of the systems (except for OpenVMS, MS-DOS and Windows where its use in file/directory name is allowed but the last occurrence will be interpreted to be the extension separator in VMS, MS-DOS and Windows) as mentioned in the Wikipedia link that follows:

In other systems, usually considered as part of the filename, and more than one period may be allowed. In Unix, a leading period means the file or folder is normally hidden.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »