The Structure of the Linux File System

Ziyad Yehia
A free video tutorial from Ziyad Yehia
Energetic Instructor with a Project-based Approach
4.7 instructor rating • 3 courses • 206,283 students

Lecture description

In this video, you will learn about the structure of the Linux file system.

Learn more from the full course

Linux Mastery: Master the Linux Command Line in 11.5 Hours

Learn the Linux Command Line from Scratch and Improve your Career with the World's Most Fun Project-Based Linux Course!

11:16:52 of on-demand video • Updated August 2021

  • Quickly Learn the Linux Command Line from Scratch!
  • Use Bash Scripts and Cron Scheduling Software to Automate Boring Tasks!
  • Become an Independent User of the Linux Operating System!
  • Learn how to Search for, Customise, Install and Manage Open Source Software with Package Managers!
  • Operate a Linux Computer Entirely from the Command Line!
  • Gain a Complete Understanding of Linux & fill in any existing knowledge gaps!
English [Auto] Hello there, you beautiful people. So one really amazing thing about Linux is the way that pretty much everything on the system can be treated as a file. Now, you saw this earlier when we did the totally awesome magic trick where we redirected data from one terminal to the other. Now, that was possible because the terminal was treated as a file by the Linux operating system. And you can redirect data between devices on your system, just like you can redirect data between files. Now, every one of the files on the system is on a structure known as the Linux file system tree. And in this video, you're going to learn how the Linux file system is structured. And you're also going to get a tour of what some of the most important places on the file system are. By the end of the video, you'll know the map of the LAN, so to speak. And by knowing what you're actually navigating and how it's laid out, you'll be much better prepared to actually navigate it and modify it. And that's what we will start learning in the next video. So you're going to learn about some very important locations on your computer and also learn what therefore which will help you navigate even better. Loads of really awesome stuff in this video, guys. So let's go ahead and get into it. The first thing you need to know is that the entire Linux file system follows a tree structure. So if there's no partitions on your hard drive, every single thing on the system can be accessed in one large tree structure. So let's go ahead and take a look at it. Here's an image of what the file system looks like now at the top of the tree, we have what we call the root directory represented by this slash here. Now, just to be clear, in case you haven't come across the word before, when I say the word directory, I basically just mean the word folder. OK, so when I say root directory, I'm just referring to the root folder on the file system. This slash here. Now, that folder is called the Root Directory because everything on the file system can be traced back to that, just like every branch and leaf on a tree can be traced back to the root of the tree. Now, under that root directorate, there's a whole bunch of other directories. These directories are said to be subdirectories of the root directory. Another way to say that is that the root directory is the parent directory for all of these directories in Orange here. Now, there may be more folders or directories present on your system, but I've taken the most important ones to show here in this image because a slide only has so much space. Now, each of these directories can have other directories and files inside of them, and the directories inside those directories can have their own directories and files and so on and so on and so on, so that the whole system does eventually look like a really big tree with hundreds and hundreds of branches. Now, one of the most important directories on this tree is the home directory. The home directory holds individual directories for each of the different regular users on the system. Here we can see that the system has three regular users. We've got Alice, Bob and Charlie, and each of those users can have their own files. So, for example, if we take Bob, we can see that Bob has folders in their home directory for their desktop document downloads, music pictures and so on. And each of those folders can have files and other folders inside them. Alice will have a similar structure and so will Charlie. You can access your home directory by clicking on this file icon over here and what opens up by default will be your home directory now, everything that we've been doing in the course up until now. So just playing with pipelines, redirection and stuff and creating files, they've all those files have all been in our home directory. And you can see that in our home director, we have a desktop document, downloads, music pictures and so on and so on, just like Bob did in the diagram. And if you're navigating around your file system, you can always get back to your home directory by clicking on this home icon here, all by finding it in the path that appears at the top. You can think of everything on the file system as being in two major parts, and this is a bit of an oversimplification, but you can think of everything below the user's home folder as being specific to that user and everything that's above the user's home folder tending to affect the whole system. Now, what good would it be if regular users could modify or even delete files that the whole system requires to run? Not very good at all. And that's why special files and folders that tend to affect the whole system usually require elevated administrator or route privileges. The root user on the system is similar to the administrator in Windows on Linux. The user has absolute power over the entire system. Now I'll show you how you can perform actions of the user in a later video. But for now, just be aware of their existence for now. I just want to discuss what these folders at the top here do. Now, there's a lot of them said to save you from memorizing. I've made a cheat sheet that you can download from the resources section in this lecture. Let's go ahead and go through it together now. OK, so as I said, you can get a copy of this cheat sheet from the resources section in this video and what it basically contains is a list of the different folders that are right underneath the root directory, right underneath the slash, and a bit of a description about what they do so that you can have a bit more of an understanding of what each of the folders does on your system. Let's just do a quick whistle stop tour of each of them and then you can look at it later in more detail for yourself. OK, so we've got the slash directory. Let me zoom in a little bit, make it make the thing a bit bigger. There we go. So you've got the slash directory, which is the very top or the root of the file tree. And this directory holds everything else. There is nothing higher up than the directory. If you get here, you are at the very top of the far tree. You've got the bin directory, which stores common Linux user command binaries, Baen binaries, which is where Bin gets its name from. For example, the date command cat come on Cao commands. They're all stored in the binaries section. In the binary folder you've got the boot folder. Boot is for everything that is required to boot the system. So bootable Linux kernel and bootloader configuration files. You've got the dev folder. So this is, these are files representing devices. Now there's many different files in that folder. If the file name starts with T.Y., that's a terminal. If it starts with F.D., that's a floppy disk. If it starts with SD or Heijne, that's a hard disk. If it starts with Ram, then it's RAM. And if it's also a CD, then it's a CD rom you've got, which is administrative configuration files. Now, ETSI or ETSI, as it's normally said, is a very common folder. You'll be using it a lot if you ever want to edit configuration files. And how you edit those configuration files is where Section five of the Linux manual comes into play, which is all about file formats and things like that. So for editing, many of the configuration files are in the folder. You'll be able to find a man page that'll show you how to do it. Then you've got the home folder and the home folder is where the home directory is for regular users are stored. So under the home folder, you'll have a home directory for each of the different uses. So for example, I have one at home slash Zyad. I have my home folder inside the big home directory. So if I had three other people on my computer called Alice, Bob and Charlie, there'd be slash home slash at a slash home flashbulb Instagram slash Charlie. But in my case, just Slusher. Zayat So that's where your home directory is stored. In the home folder you've got slash media, which is where removable media such as USB sticks, external hard drives and things are mounted. Anything that is removable from the system, unlike hard drives, unlike actual hard drives, anything that's removable usually gets mounted on slash media. Slash lib is where shared libraries so lib being short for libraries need to buy applications in the slash business espin folders to boot the system. So this is where all that stuff is all loaded. Basically loads of installed stuff because it's lib slash MMT is a place to mount external devices. You don't use that often. Usually media is used instead slash misk. Being short for miscellaneous is a directory used to sometimes automate filesystems. It's just there just in case so the system can use it. Slash Opti or UPT is where you can store additional or in other words, optional software. So anything that you install, any programs that you install, usually the files go in. Slash, opt, slash proc is about system resources as more administrative kind of stuff slash route. Now this is the home folder for the route user. So this is sometimes a point of confusion. You've got the root folder, which is the slash, sometimes called the slash directory, and you've got slash root and slash root is the home folder for the root user. So it's a bit of a confusing terminology. But just just bear in bear that in mind. Okay, the slash is the root directory. It is the very top of the file tree and slash root is the home folder for the root user or the super user or the administrator similar to the administrator. If you're on Windows, that's the home directory for the administrator almost there. Now you've got Slash S-Bahn, which contains administrative administrative commands or binaries for the root or super user. So Espin being super user binaries. OK, so these are commands that can be run by the super user or the router user. You've got Slash TMP, which contains temporary files run by applications. Sometimes when programs are running, they create temporary files to make them more efficient to run. That's where those are stored and the temp folders usually cleared out very regularly or when the programs shut us all user contains files pertaining to users that in theory don't change after installation and slash VAR contains directories of variable data. So data that changes a lot that could be used by various. So, for example, system log files are usually found in here, log files change a lot, so that's why they're in the slash or slash variable slash of our being short for variable. So there you are. These are the different folders that are on at least the most common ones that are directly underneath the slash folder. So have a look at this cheat sheet, read through it once again. And, you know, maybe with my video, with my voice playing in the background, you don't have to memorize this. The cheap seats there, just in case you don't have to memorize this stuff, you'll very quickly become familiar with the most common ones that you'll use. Most likely you'll just stick to using ETSI, which is where configuration files are the home folder and maybe media if you plug in a USB drive or something like that and maybe use if you want to edit something to do with programs. But usually those are the most common ones you'll be you'll be dealing with, but you'll become very familiar at where files are will be using a lot of these different folders as we go through the course. Don't worry if it all seems like a bit worse right now, that information is there forever. Just take it take it one step at a time. Don't be overwhelmed by it. You're going to it's going to be fine and you'll very quickly become accustomed to it. OK, so there you have it. You should now have a much better understanding of the Linux file system and how it's structured. So as a quick recap, we discussed at the Linux file system follows a tree like structure starting at a base directory which is represented by the slash. Now you learn that everything on the file system can be traced back to that base directory. You also learn that there's a special user on each Linux system called the router user. The root user is similar to the administrator on Windows and the user has absolute power over the entire system. They can do anything that they want. You learn that the home directory or the home directory holds individual home directories for all the regular users on the system so that they have a place to store their personal files. And you learn that the root folder is the home directory for the root user, for the administrator. You also had a look at a bunch of really important folders that are right underneath the base directory. And there's a cheat sheet that you can download in the resources section where all that information is summarized for you. OK, brilliant. So now that you understand the whole structure of the file system, which is totally epic in its own right, I've also put a link to a series of blog posts in the resources section that will later learn more about the Linux file system if you want to. But now we're going to go ahead and jump in to using the command line to start navigating the file system, which is going to be really exciting. So for all that goodness, I'll see you in the next video.