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? What about sharing these directories with a Windows user?
Here is Solutions:
We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.
As far as I know there are 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
. in front of it 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:
- 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).
- 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
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: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂