Beginning Linux users are met with a huge mountain of information to learn. What is this terminal thing? How do I run software updates? Which distro do I choose? Those are all common questions. However, there’s a question that still plagues many more experienced Linux users: what’s in each of the directories in the Linux virtual directory system? Here we cover everything from “/” to “/boot” in our guide to the Linux virtual directory system.
What Is Linux Virtual Directory System?
A Virtual Directory System is a way of organizing files and directories in a computer operating system. The reason why it’s called “virtual” is that there’s no actual physical component – on Window, you have your “C:” drive, “D:” drive, and so on. On Linux, all physical disks are treated as files in your virtual directory system. This is where the phrase “everything is a file” comes from. Even the disk in your system that you’re working off of for your operating system is treated as a file.
Understanding the Virtual Directory System
The root directory: /
Let’s start with the very beginning. The “/” (or “root”) directory is what contains everything in the system. By running the
cd / command, you’re zooming out as much as possible on your system. Change to the “/” directory and run the
ls command. You’ll start to see what I mean. Rather than “Documents,” “Downloads,” or “Pictures,” you get things like “bin,” “dev,” and “home.” It’ll be a little bit different depending on your distro, but there are some core directories that will pretty much always be there. All directories from here will have “/” at the beginning of them because that’s the very root of everything – hence the name “root.”
The Binary directory: /bin
The “/bin” directory holds all of the binary programs in your system. If you look in there, you’ll see common commands like
ls that we’ve already used. You can also find them by running the
which cd or
which ls commands. Most of the time on modern distros, the “/bin” directory is linked to the “/usr/bin” directory. The “/usr” directory is covered later, but in short, they are used to separate binaries meant for the system and administrators in the “/bin” directory and the system users in “/usr/bin.”
The Boot directory: /boot
The “/boot” directory holds all of the very basic information that your system will need to start up. All of the kernels you have installed on your system, all of the config files for those kernels, information for Grub – all of it. It’s a very important directory, and it’s treated as an EFI system partition separate from your system. That’s why when you create manual partitions, you need to make at least “/” and “/boot” separately.
The Devices directory: /dev
The “/dev” directory holds all the device files in the system, which are all the hardware components on your system (as well as some other important virtual devices like “null” and “random.”) Looking at it, you’ll notice things like “cpu,” “sda,” “tty,” “stderr,” “stdin,” and “stdout.” Those are all important device files you’ll interact with on a daily basis.
The Etc. directory: /etc
This is for random stuff. The “/etc” directory, pronounced like Etsy, is where you’ll find lots of configuration files for most things in your system. Things like SSH, Pipewire, systemD, and Firefox all have configuration files here. It’s sort of the junk drawer of the Virtual Directory System – super important but a little cumbersome to find things in.
The Home directory: /home
The “/home” directory houses all personal files for users. When a user is created, they’re generally given a “/home” directory and permissions to edit only the files in their “/home” directory. Some users are also given admin rights, which is what
sudo nets you, but that’s just assuming the rights of the root user. If you run
sudo whoami successively, you’ll start to see that. This is the directory you’re likely most familiar with.
The Library directory: /lib, /lib32, and /lib64
The “/lib” directories all contain specific libraries that the programs in “/bin” or “/sbin” (covered later) will use. This is where firmware is stored, along with other libraries for installing different parts of the kernel and Kernel Modules. The sister directories “/lib32” and “/lib64” just contain versions for 32-bit and 64-bit operating systems and are almost identical to the base “/lib” directory.
The Media directory: /media and /mnt
I’m grouping these together because they often serve the same purpose. The “/media” directory is where the contents of CDs, DVDs, or other removable media are stored. If I plug in a USB drive, you’ll see it pop up in “/media” on most systems.
The “/mnt” directory is used for longer-term mounts. For example, if I were to add another SSD to my system, I may set up a permanent mount point for it in the “/mnt” directory. Or, if I have a NAS in my home, I may mount that information in the “/mnt” directory as well.
The “/opt” directory houses additional software packages for use by a user. It’s a lot smaller than you’d think – mine only houses files for Brave, Google Chrome, and Sublime Text. If you add a repository for a piece of software, you’ll probably find that in “/opt.”
The “/proc” directory houses hardware information and ongoing process information. As the system figures out what the hardware landscape looks like, that’ll get stored in the “/proc” directory. For example, if you run the command
cat /proc/cpuinfo, you’ll learn more about your CPU than you ever thought you wanted to know.
This is just the root user’s version of a “/home” directory. If you do a lot of work as the root user, you’ll find stuff in there.
The “/run” directory is somewhat similar to “/proc” – just that instead of hardware, “/run” focuses on software. Both store what’s called “volatile runtime data,” meaning these directories are pretty much cleared out each time you reboot the system, but they store helpful stuff as the OS learns more about your system and what you’re using it for.
The “/sbin” directory houses binary programs that should only be made available to the root user. For example, the binary program that powers off your system (
poweroff) should probably stay in “/sbin.”
This is the directory that holds site-specific data based on the Web-accessible services you’re running. Things like FTP and HTTP will have specific information stored here. I’m not running any, so my “/srv” directory is empty.
The “/sys” directory houses information on key devices in the system. In mine, you’ll see things like “/sys/dev,” “/sys/firmware,” and “/sys/kernel.” This is a cherry-picking of the super important hardware devices in the “/dev” directory.
The “/tmp” directory is used to store temporary information from various programs on your system. Information is stored here for just a couple of days without a reboot, so it’s just temporary locks on information to keep other storage space free. There isn’t much most users will ever have to do with the “/tmp” directory.
The “/usr” directory is becoming more and more commonly touched. Now, directories like “/bin,” “/lib,” and “/sbin” are linked to versions of those directories in “/usr.” You can see that when I run the
ll command on my system.
They’re soft links, so they can be unlinked, but the system ends up reading from the “/usr/bin” or “/usr/sbin” directories, rather than the “/bin” or “/sbin” directories. This is all done to simplify the hierarchy present and make it simpler to find these programs. It’s a nice quality-of-life thing that makes it easier to switch from Linux to Unix or not have fixed locations to different binaries.
The “/var” directory is similar to the “/tmp” directory, but it holds data for a little bit longer. It also stores things like log files and KVM Virtual Machine disk images.
As you can see, the Linux virtual directory system is meant to organize the files that your system will use and make it simpler to administer and manage your system. Obviously, you can do whatever you want with this system (that’s the beauty of Linux), but leaving things the way they are is fine and dandy for most desktop users. You may also want to find out which filesystem is the best for Linux in 2021.