In Linux, / (a single forward slash) is the root directory: the top of the one file tree that holds every file and directory on the system. A path that starts with /, such as /etc/hosts, is an absolute path that is looked up from that top directory.
You can see it yourself. Run these two commands in any terminal:
cd /
ls
Example output (the exact list differs by distribution):
bin boot dev etc home lib media mnt opt proc root run sbin srv sys tmp usr var
Each of those names is a directory directly under the root. Together they form the layout every Linux system is built on.
What the root directory is
The hier(7) manual page, which describes the file system hierarchy, defines the entry for / in four words: "This is the root directory." The rest of the page lists what sits beneath it. Everything on a Linux system, including files on other disks, appears somewhere in this single tree.
This is the biggest difference from Windows. Windows gives each volume its own drive letter and its own top-level folder (C:\, D:\). Linux has one top. A second disk does not get a letter. It is mounted at a directory under /, and its contents appear inside that directory. The hier(7) page describes /media as the place for mount points of removable media such as CD/DVD discs and USB sticks, and /mnt as a mount point for temporarily mounted filesystems.
What / means at the start of a path
The path_resolution(7) manual page explains how the kernel reads a path. If the pathname starts with the / character, "the starting lookup directory is the root directory of the calling process". Such a path is called an absolute path. Without the leading slash, the lookup starts in the current working directory, which makes it a relative path.
| Path | Type | Starts looking in |
|---|---|---|
/etc/hosts | Absolute | The root directory |
etc/hosts | Relative | The current directory |
../etc/hosts | Relative | The parent of the current directory |
/ | Absolute | The root directory itself |
A slash in the middle of a path has a different job: it separates one name from the next. In /etc/hosts, the first slash means "the root", and the second separates the directory etc from the file hosts.
You cannot climb above the root. The same manual page says that "/.." is the same as "/". So cd / followed by cd .. leaves you where you were.
What is inside /: the standard directories
These descriptions follow hier(7). Distributions follow this layout closely, but check your own system with ls /, because some directories are optional or absent.
| Directory | What it holds |
|---|---|
/bin | Executables needed in single-user mode and to bring the system up or repair it |
/boot | Static boot loader files; the kernel must be in either / or /boot |
/dev | Special or device files that refer to physical devices |
/etc | Configuration files that are local to the machine |
/home | User home directories, on machines that have them |
/lib | Shared libraries needed to boot the system and run commands in the root filesystem |
/media | Mount points for removable media such as USB sticks |
/mnt | A mount point for temporarily mounted filesystems |
/opt | Add-on packages that contain static files |
/proc | Mount point for the proc filesystem, which provides information about running processes and the kernel |
/root | Home directory for the root user (optional) |
/run | Information describing the system since it was booted |
/sbin | Commands needed to boot the system that normal users usually don't execute |
/srv | Site-specific data served by this system |
/sys | Mount point for the sysfs filesystem, which provides kernel information in a more structured form than /proc |
/tmp | Temporary files that may be deleted without notice, such as by a regular job or at boot |
/usr | Shareable, read-only data |
/var | Files that may change in size, such as spool and log files |
Two of these trip people up. /proc and /sys are not stored on disk as ordinary files. They are mount points for special filesystems that expose information from the kernel, which is why cat /proc/cpuinfo works even though you never created that file. And on many current distributions some of the older directories, such as /bin, are links into /usr. You can check on your own machine with ls -ld /bin: a leading l in the output means it is a symbolic link.
/ versus /root versus ~
Three things get confused because they sound alike:
/is the root directory, the top of the tree./rootis a normal directory one level down. Perhier(7), it is the home directory for the root user, the administrator account.~is a shortcut your shell expands to your own home directory, for example/home/alex. It is not the root directory unless you are logged in as the root user, and even then it expands to/root, not/.
To confirm where you are, run pwd. It prints the absolute path of the current directory, and prints just / when you are at the top.
Why the root directory is protected
Normal users can read most of / but can write to little of it. Their own files live under /home, and temporary files go in /tmp. Changing /etc, /usr or /boot needs administrator rights, usually through sudo. That is a deliberate permission setting, and ls -ld / shows it. Example output:
drwxr-xr-x 20 root root 4096 Nov 10 09:12 /
The owner (root) can read, write and enter the directory. Everyone else can read and enter but not create or delete entries directly in /. If the permission string is new to you, see how to read ls -l output and Linux file permissions and chmod.
This is also why a command like rm -rf / is notorious. It asks the system to delete everything reachable from the top of the tree. The slash in a path is an instruction to start at the very top, so check any command that begins with / twice before running it as an administrator.
A different root: chroot and containers
The root directory is a property of each process, not one fixed place. The path_resolution(7) page says a process inherits its root directory from its parent and may get a different one through the chroot(2) system call. Inside such a process, / points at a different directory on the real disk. A separate mount namespace can also change what / shows. This is the basic mechanism behind tools that run programs in an isolated view of the file system, so a / inside one of those environments is not the host's /.
Where to go next
If you are learning the terminal, the commands that matter most with / are cd, ls and pwd. They are covered with other everyday commands in basic Linux commands. A good habit is to type cd /, run ls, and then walk through the directories above with ls /etc or ls /var. Reading the layout on your own system teaches more than memorising it.
Frequently asked questions
- What is the difference between / and /root in Linux?
- / is the root directory, the top of the whole file tree. /root is an ordinary directory under it that serves as the home directory of the root user (the administrator account). They share a name but are unrelated places.
- Why is there no C: drive in Linux?
- Linux uses one tree that starts at /. Extra disks, USB sticks and network shares are mounted at a directory somewhere under /, such as /media or /mnt, instead of getting a drive letter.
- What happens if I run cd / and then cd ..?
- You stay in /. The path_resolution(7) man page states that one cannot walk up past the root: /.. is the same as /.
- Does / mean something different at the start of a path than on its own?
- Both refer to the root directory. A path that starts with / is an absolute path and is looked up from the root directory. A / between names, as in /etc/hosts, separates one directory or file name from the next.