File names#

Starting from a Windows Systems there are some important differences regarding file names in Linux file systems. In Linux files paths are written with / as separators (opposed to Windows using back slashes \) and Linux files systems are usually case sensitive, i.e. file.dat and File.dat are different files.

On most Linux file systems the name of a file can be up to 255 characters long and may contain any characters except slashes / and NULL characters (\0).

Portable filename character set

It is advisable to use only filenames with characters from the portable filename character set [-._a-zA-Z0-9]. That is letters a-z and A-Z, numbers 0-9 and the characters -, . and _. Other characters as whitespaces, parenthesis or * have a special meaning and it is difficult to handle such filenames correctly. For example rm My Notes will delete the files My and Notes, instead of deleting the file “My Notes”.

Absolute and relative paths#

There is a distinction between relative paths and absolute paths. An absolute path describes an absolute position in the file system, i.e. with respect to the file system root / it always starts with a slash:

/home/alice/Documents/notes

A relative path describes a file with respect to the current working directory. It is always written without a leading slash:

Documents/notes

Assuming the current working directory is /home/alice then the two paths from above refer to the same file.

More absolute paths#

Sometimes paths are written with a leading dot such as in ./foo/bar. This is also an absolute path, as . is actually a name for the current working directory. So for example if the current working directory is /home/john, then ./foo/bar is equivalent to /home/john/foo/bar.

Another subtlety are expressions like ~/foo/bar. In this case ~ is a feature of the bash shell. Before the execution of a command bash substitutes ~ with the current users home directory. So ~/foo/bar will be replaced by the absolute path /home/john/foo/bar.

Note

There is a important distinction. While . is actually a file in the file system, ~ is not. It is just a handy short cut provided by bash.

Hidden files#

By convention, files staring with a dot character (.) are hidden files. They are not included in normal file listings and are not shown graphical file explorers. A typical example would .config.

Each directory contains two files . and ... They are actually directories or merely alternative names: . is a name for the current directory
and .. is a name for the parent directory. For example foo,foo/., foo/bar/.. are all names for the same directory foo. Also see the hard links. In particular . and .. are hidden files, as their name begin with .!