Frequently Asked Question
What do '.', '..' and '~' mean in a path?
Every directory contains two automatic entries: . refers to the directory itself,
and .. refers to its parent. They exist as real entries in the directory file, so
you can see them with ls -la. The single dot is how you run a program from the
current directory, ./myscript.sh, because for security the current directory is
not normally on PATH. The double dot lets you climb the tree without spelling it
out: cd .. goes up one level, cd ../.. goes up two, ../other means the sibling
directory next to this one.
The tilde is a shell convenience, not a filesystem entry. When bash sees ~ at the
start of a word it expands it to the home directory of the current user, so
~/Documents becomes /home/chris/Documents. ~alice expands to user alice's
home, and ~+ and ~- expand to the current and previous working directories. The
kernel never sees the tilde; the shell rewrites the path before the program is
called.