- The Model Context Protocol: Simplifying Building AI apps with Anthropic Claude Desktop and Docker | Docker
- This robot vacuum and mop performs as well as some flagship models - but at half the price
- Finally, a ThinkPad model that checks all the boxes for me as a working professional
- Why I recommend this Android phone for kids over a cheap Samsung or Motorola model
- My favorite USB-C accessory of all time scores a magnetic upgrade
The Linux file system structure explained
The way the Linux file system is laid out makes perfect sense. I’ve been using Linux for so many years that I can’t imagine another file system making more sense. When I consider how the Windows file system is laid out, my eyes gloss over and I can only think, “What?” and “Why?”
Also: I’ve used Linux for 30 years. Here are 5 reasons why I’ll never switch to Windows or MacOS
However, for those who are new to Linux, those file system names might not make any sense. That’s okay because I’ll clear up the confusion for you. Don’t worry, I’ll do this in a way that anyone can understand.
Let’s get started.
At the root of all things
Root (aka “/”) is where all other directories are found. If you issue the command ls /, the output will include directories like bin, boot, dev, home, etc, media, mnt, opt, sbin, srv, and var. The root directory is the parent of all directories on the system. Root is similar to Windows C: directory.
Also: Thinking about switching to Linux? 10 things you need to know
One thing to remember is that standard users do not have full access (including write access) to most directories under root. In fact, the only directory users have full rights to is their home directory.
Let’s go home.
Home
Home is the directory that houses all user directories. For example, you might have /home/olivia. That directory is where all of user olivia’s files, folders, and unique configurations live.
Also: The best Linux distros for beginners: You can do this!
If you have multiple users on the system, home will include all user’s directories.
Home is also known as ~/ and $HOME. Just because all user directories are housed in home, it doesn’t mean one user can access another user’s folders and files. Let’s say you have user olivia and user nathan on your system. User olivia will not have access to /home/nathan and user nathan will not have access to /home/olivia.
bin and sbin
Both of these directories contain executable binaries for applications and commands. The big difference is that bin contains essential binaries for the basic operation of the system (such as commands like ls, cp, mv, mkdir, and more), and sbin contains system binaries required for admin tasks (such as fdisk).
usr
The usr directory is where things can get confusing because it also contains executable binaries and libraries for the system. The difference, however, is that this directory is where executable binaries are added when you install an application.
Also: 5 Linux commands you need to know to troubleshoot problems
For example, if you install LibreOffice, the executable file for Writer will be /usr/bin/lowriter. If you issue the command ls /usr/bin, you’re running a command found in bin on the directory /usr/bin and the results will not only include all of the binaries for apps you’ve installed but all non-essential binaries. The usr directory also contains system administration tools and development libraries.
etc
The etc directory is where you’ll find configuration files for the system and its applications. Network configurations, user account information, and systemwide settings are found in this directory.
opt
The opt directory is used for optional software that is installed on the system. When you install third-party software (such as Chromium, Termius, Vivaldi, and MS Edge), you’ll find directories for those applications.
Also: Why I use the Linux tree command daily – and what it can do for you
For example, if you install MS Edge, you’ll find the directory /opt/microsoft, which houses all the libraries and executables necessary for that application to run.
boot
This is where all the files required for the boot process are housed, which includes the kernel, initial RAM disk, and the bootloader configuration files.
lib
The lib directory houses all essential libraries that are required by applications on your system.
media
The media directory is where removable media (such as external drives and DVDs) are mounted and accessed.
Also: The best Linux laptops
If you connect a USB drive to your system, the contents will appear in a sub-folder within /media.
mnt
This is similar to media, only it’s used for mounting other file systems (such as network file systems).
proc
The proc directory houses files that contain information about processes. In this directory, you’ll find a collection of numbered sub-directories, each of which is associated with a running process.
root
That’s right, the root directory (called “/”) also contains a directory called root. This directory serves as the home directory for the root user. But why not place it in /home/root? The reason is that the root user needs extra system protections, so it gets its own directory. Most modern distributions don’t ship with the root user enabled (which is good for security), so this directory won’t be used much.
run
This directory contains runtime data, some system logs, process IDs, and temp files. You will most likely never touch this directory (nor should you).
srv
The srv directory houses data for services, such as web and FTP servers. This directory is only used if you have such services installed.
Also: Do you need antivirus on Linux?
If you’re using a desktop distribution, srv will probably be empty. If you were to install an FTP server, you might create a directory in /srv to house the upload and download directories.
tmp
Temporary files (created and used by applications) are held in this directory and are regularly deleted.
var
The var directory houses system logs, mailboxes, spool files, and the document root of your web server (if you install one). Should something go wrong with your system, /var/log is one of the first places to start troubleshooting.
Also: How to choose the right Linux desktop distribution for you
Of the above directories, the only one you’ll definitely interact with is your user directory in /home. Beyond that, you’ll use /etc, and /usr quite a bit. Of course, if you attach external drives, /media will be important. The chances of you having to dive into the other directories are slim, but at least now you know what they contain.