~ For Home And / For Root Directories In Linux And Mac: Why Were These Symbols Chosen?
In the past, we’ve written a dedicated article to explain the Linux file system hierarchy. This file system tree starts from root and branches out to other directories like bin, boot, dev, etc. In this article, I’ll be focusing on Home and Root directories and their signs.
Usage of / for Root directory
Everything stored on your Linux machine is stored under the root directory, which is denoted by /. Please note that / directory is different from /root, which is root user’s directory.
The forward slash, i.e., / symbol, is very common in Unix-like operating systems and their paths. It was introduced around 1970 as the directory separator. It’s also recognized by most programmer-level APIs. This brings us to the question: Why is root directory denoted by / sign?
The reason behind the selection of / as root directory symbol is related to the predecessor to Unix, the Multics operating system. Multics used the character > as the path separator. However, Unix designers had already reserved characters > and < for I/O redirection on the shell command line long ago.
Back then, the Lear-Siegler ADM-3A terminal (Source: Wikipedia) was in common use. This wasn’t a computer, but it let you input commands and display data from a computer. As the designers had to use another character for path separator, they choose / key, which was next to > key (Source: Superuser).
The denotation of root directory with a sign / is probably due to the fact that it’s the top-level directory and there’s nothing beneath it. So, it made sense to denote root directory with just this single character as there’s nothing above or outside it.
Usage of ~ for Home directory
Just like root directory symbol, the home folder too has its sign, which is tilde (~). In the terminal, you can simply type cd ~/X and jump to X folder in your home directory that contains your personal data. The ~ symbol is something that shell uses to replace the current user’s home directory.
The history of usage of ~ for denotation of Home directory again relates to same ADM-3A terminal. As you can see in the picture above, the Home key is the top right. This key works just like our modern keyboards that makes the cursor jump to the top-left position while typing. In the same picture, you can see that the same key is used for typing ~ symbol. This relation helped tilde symbol to represent home folders.
Cursor keys in Vi
This isn’t all. This terminal also went on to become the influence behind the fact that H, J, K, and L keys are used to move the cursor in Vi text editor. This also became an indirect inspiration for keyboard shortcuts in Gmail, Facebook, etc.
Did you find this nerdy information interesting? Do you know some more facts that might interest other Fossbytes readers? Don’t forget to share them with us.
Also Read: 10 Most Dangerous Linux Commands You Should Never Run