Understanding the Linux Virtual Directory Structure

Linux Virtual Directory Feature

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.”

Linux Virtual Directory Fedora
Linux Virtual Directory Ubuntu

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 cd and 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.”

Linux Virtual Directory Which Cd

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.

Linux Virtual Directory Boot

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.

Linux Virtual Directory Lsblk

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 whoami and sudo whoami successively, you’ll start to see that. This is the directory you’re likely most familiar with.

Linux Virtual Directory Whoami

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.

Linux Virtual Directory Lib

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.

/opt

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.”

/proc

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.

/root

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.

/run

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.

/sbin

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.”

Linux Virtual Directory Which Poweroff

/srv

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.

/sys

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.

Linux Virtual Directory Sys

/tmp

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.

/usr

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.

/var

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.

John Perkins John Perkins

John is a young technical professional with a passion for educating users on the best ways to use their technology. He holds technical certifications covering topics ranging from computer hardware to cybersecurity to Linux system administration.

One comment

  1. I have used Linux for over ten years, and still have problems finding things in the directory at times. It took me a long time to figure out even what I know. Home, Home> (hidden) .config, usr>bin, usr>share and mnt are the ones I use the most.

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.