What you'll learn
- Explain the Filesystem Hierarchy Standard, navigate to the filesystem root, and use man hier to look up each top-level directory
- Identify the purpose of system directories such as /boot, /etc, /lib, and /var on a Linux system
- Describe how device files in /dev connect the system to hardware and use /dev/null and /dev/random in admin tasks
- Inspect process directories by PID and files such as interrupts and filesystems in the /proc virtual filesystem
- Explain how the /sys virtual filesystem exposes kernel module, hardware, and driver information in real time
- Explain how the PATH environment variable locates system binaries and why relaxed directory permissions create an attack vector
Free 49-minute video lesson with a full transcript and knowledge checks. No account needed to watch.
Overview
Join John McGovern as he explains and demonstrates core fundamental concepts and practices relating to Linux system management
Recommended Experience
- None
Related Job Functions
- Systems Admin
- Systems Engineer
A former CBT Nuggets learner, John used online IT training to help him build a diverse skill set, which includes networking and cybersecurity.
Introduction
Let's talk about what we plan to learn about the Linux file system in this skill!
FHS Basics
Let's discuss of the basic fundamental concepts behind the Filesystem Hierarchy Standard!
Knowledge Check
(True or False) All Linux distributions must strictly adhere to the Filesystem Hierarchy Standard.
FHS System Files and Directories
Let's look at some of system files and directories within the Filesystem Hierarchy Standard!
Knowledge Check
In which directory would you expect to see log files?
The Dev Directory
Let's now explore the /dev directory!
Knowledge Check
Which of the following outputs would refer to the 1st partition of the 1st hard drive connected to the system?
The Proc Directory
Let's now turn our attention to exploring the /proc directory!
Knowledge Check
(True or False) The /proc directory is a virtual directory created on the hard disk.
The Sys Directory
Let's /sys directory is a virtual file system that holds many important files for our system - let's explore it!
Knowledge Check
(True or False) The /sys directory contains files relating to kernel modules.
FHS User Files and Directories
Let's now turn our attention to the user files and directories in our system!
Knowledge Check
Which of the following is designed to be used to mount temporary file systems?
FHS System Binaries and Programs
Let's now look at our last grouping within the Filesystem Hierarchy Standard, the system binaries and programs!
Knowledge Check
(True or False) The /opt directory is there to contain optional third-party packages.
Conclusion
I hope this has been informative for you and I would like to thank you for consuming.
View Transcript
Introduction
0:12Hey, everyone, and welcome back to another skill. Within this skill here, we're going to look at how we can identify and locate system files and directories. Specifically, we're going to be taking a great interest in the /dev directory, as well as the /proc directory, and the /sys directory. Now, once we have explored our system files and directories, we're then going to pivot and then have a look at some of the user files and directories on the system. And then once we have done this, we're going to close by learning where we can find system binaries and programs within our directory structure.
0:48So really, we have a lot of very cool stuff to get to within this skill. Now, before we start, just to ensure that you are absolutely comfortable working at home, following along with this lab, what I just want to do is to highlight to you how you can quickly set up your terminal window to suit your needs. As you may see here, the output that I'm looking at is a little bit small. If I want to be able to adjust the font so it's nice and easy on my eyes, the way I can do this is that-- in fact, let me just close this down for a second here. I'll go down to the bottom left here. Just type in Terminal.
1:18Choose this one right here. I will have the Maximize icon. And then I'm going to go to this hamburger icon right here. If I then choose Preferences and I go down to Unnamed-- that's just going to be my current profile-- what I can do here is I can select a custom font and then click here. And basically, I can choose the font that I want. Let's maybe go into Ubuntu Mono, but I want the font to be bigger. So let me just arrow up [INAUDIBLE] get that bigger. If I then choose Select, we can see, here, immediately the text is bigger.
1:48If I want to change the color, I can uncheck the Use Colors from System theme. And then basically, I can choose the color that I want. So maybe I want to have black on white or gray on black. If you want to be a master robot-style hacker, you can do the green on black. Then all your text is now in green. So for now, all I'm going to do is I'm going to set my preferences as I'll have that white on black. And know that I'm happy and comfortable with my terminal setup, what I'm ready to do is to begin labbing. The very first thing that we're going to talk about is the basic pane-- something called the FHS.
2:22What on Earth is that? Well, that's what I'll be talking about in the very next Nugget. But for now, I hope this has been informative for you. I'd like to thank you for viewing.
FHS Basics
0:12Hey, everyone, and welcome back. So in this Nugget right here, what I want to talk to you about is something called the Filesystem Hierarchy Standard, otherwise known as the FHS. So what exactly is the Filesystem Hierarchy Standard? Why do we want to know what this is and what it does for us? Well, the clue is in the name. It's all about how our file system is going to be laid out. It's going to be laid out-- any particular hierarchy. And this is something that is standardized. Now, I will say, standardized, in a kind of loose way.
0:44This is something that is not mandatory. Not all Linux systems have to implement the FHS. It's something that is looked at is more of a good practice, or maybe, should I say, general consensus. Quite simply, if you happen to boot up your Linux-based operating system, there is a high degree that the file system is going to follow this particular format. Now, you will see, in other Linux filesystems, additional directories, maybe things look a little bit different here and there. But very, very broadly these are the components that are going to make up the filesystem that you would interact with.
1:16So realistically, what we have to understand here is what exactly comprises of the Filesystem Hierarchy Standard, what of the directories involved here, and what is the purpose of each of those directories because the reality is they really are quite specific, which honestly makes sense the management much, much easier because once you learn what the Filesystem Hierarchy Standard is, you are pretty much going to know exactly where to go to solve the problem that you're looking for. Whether you're trying to mount a device within the file system or whether you want to happen to try to identify which devices are connected to your machine, knowing the layout of the filesystem is going to be very, very beneficial.
1:53Let me give you an example of one of the big distinctions of the Linux filesystem. Compare this to how it works on say, for example, a Windows-based system. Well, the file system is directly tied to the physical hard drive. What do I mean when I say that? Well, if you happen to come from a Windows-based system, you may happen to have a C drive as well as a D drive. Now, if you wanted to locate-- say, for example-- the Downloads folder within your C drive, you would follow a very particular path. It would be something like-- say you go into the C drive, and then you go into the Users directory, and then you would have your user name, such as John, and then you would have your Downloads folder.
2:32Now, the crucial thing to note here is that this folder is explicitly within the boundaries of this physical drive. You see that? And similarly, if you went onto the D drive, you would have a same thing. Whatever path you ended up, that would belong to this particular drive. That is not necessarily the case when it comes to Linux directories. Instead, when you happen to navigate the Filesystem Hierarchy Standard, quite honestly, the physical hardware that is holding the data is completely abstracted away from you due to the way the disk may or may not be partitioned.
3:03You may go on to say, for example, the Downloads directory here. And you could be accessing data on one hard disk, and then you just change into another directory-- say, for example, the Documents directory, and suddenly you are accessing a completely different disk. Or maybe the Downloads directory and the Documents directory are on the same disk. The point is you can explicitly just tell, simply by looking at the directory path, so to speak, the same way you could on a a Windows-based system. So what I mean when I say that is if I go into Documents, I could be on one disk, whereas if I go into Downloads, I could be on a completely different disk.
3:39It is completely transparent to the end user. Now, there actually are particular ways, that we will get to see later on within this course-- how to determine where exactly all the filesystems are physically mounted. But the point is is that you as the end user, just going about your job, day to day-- it's all very smooth and transparent. So what we're going to do within this skill is we're really going to focus in on the structure of this standard. Now, one thing I just want to say is that if we happen to go back and I type in the command man hier and hit Enter, this is going to give me a very comprehensive summary of all the different endpoints that you can find within this directory structure.
4:18We can see, here, there are a ton of different options. What we have to understand, for the purposes of the examination, is not absolutely every single thing that you see here, thankfully. But there are some core components that we want to know about. Now, before we begin, one point that I just want to make really quite clear-- because it can be a little bit confusing if you are just getting started with Linux-- we have this concept of the routes of the filesystem. Now, that is located at this particular point. If I do cd forward slash and hit Enter, now I'm in the root of the file system.
4:51We can actually see this here. There's a little forward slash icon in the prompt. And if I do an ls to list my directory structure, these are the components of the Filesystem Hierarchy Standard that we are going to focus in on. So this point here is the root file system. And as we're going to learn here, we also have this root directory. These are absolutely not the same thing at all. We will certainly get to talk about the differences later on within this skill. But really before we get going, just understand that this here-- what we're talking about-- is at the root of the tree, meaning that everything that you see here all belongs within this directory here.
5:28So now that we've discussed the absolute basics around the Filesystem Hierarchy Standards and we have navigated to the root of the tree, how about we talk about the particular components that make up this Filesystem Hierarchy Standard. And the first thing that we want to be looking at relate to System Files and Directories. And well, that's we're going to be talking about in the very next Nugget. So I hope this has been informative for you, and I'd like to thank you for viewing.
FHS System Files and Directories
0:00[AUDIO LOGO] Hey, everyone. And welcome back. Now, previously, we had just introduced some of the most basic concepts around the file system hierarchy standard. What we now want to do is to look at some of these system files and directories within the fsh. So with that said, let's dive in and begin. So as we know, we're at the very rich of a tree here.
0:32And we have all of these different directories to explore. The very first directory that I'm going to show you is going to be the boot directory. So if I do CD and go into boots, and hit Enter, this is where all the files, which are needed for your system to boots are located. So you're going to see things such as the kernel image, bootloader files, the initial RAM disk image, as well as files just relating to your kernel configuration. We can see here config 5.15.0.67. That here tells us the particular kernel version.
1:03And that is going to contain like, I say, particular configuration settings. Here, we can see the initrd, the initial RAM disk image for this particular kernel version, as well. Notice they match up right here and here. And the initial RAM disk is actually going to be used by the Linux kernel. When the system is putting up to allow us to load all the particular modules, it needs as well as all the associated drivers. Now, if we look at this particular directory here, grub. That contains all of the files needed by the grub bootloader. Now, we actually haven't discussed the grub bootloader quite just yet.
1:37But don't worry. We'll get to that very, very shortly. Just understand that it's just relating to the booting up of our system. And these particular files can be located within the boot directory. Now, we also see this vmlinuz. And that is linuz with a Z not an X. That's just basically your Linux kernel executable file. Once again, like I say, located within the boot directory. And one thing to note here is that when you happen to see a Z here, that actually tells you that this is the compressed version of the executable file.
2:07Whereas, if it says vmlinux with an X, that tells you that you have the uncompressed version. Just a bit of trivia in the case of, perhaps, maybe, say, an examination question. So without going into too much detail to early, the boot directory, like I say, this is just full of files needed to boot the system. The next directory I want to go to is I apply CD root to go back to the root of the tree. And I go into the eetc directory here. Quite simply, this is where your system's configuration files are located. We see a lot of dot confs here, for example.
2:39One thing to note here is that all of these blue files, we can see here, these happen to be directories, which contain even more subdirectories or files. And the white ones here are simply just the files themselves. So let's say I wanted to make some configuration changes to the networking on my system, where I would go would be into the etc directory. And then I could go into netplan. And then I can modify this particular YAML file. So right now, we can see here that my ethernet interface is effectively getting its IP address automatically via protocol known as DHCP.
3:12But if I so wish, I could specify a particular address, specify a particular gateway, or DNS servers. And like I say, this configuration change would happen within the etc directory. And there are way, way, way more examples than just simple network configurations. But let's move on. So the next directory is going to be the Lib directory at figure 1 here. Essentially, this is where all the important libraries that your system needs to operate are located. So we have libraries, such as apt, which is used for package management or cups, which is used to handle our printers.
3:46Or we can see here, we have libraries relating to the Python programming language. Or if we want to be able to listen to music on our system, we can use rhythm box, or perhaps work with some documents using libreoffice. All of these libraries are located right here in Lib. Now, the next one that I want to talk to you about, let's go back to the root of the tree, clear the screen. The one here is this one right at the very end, the VAR directory. So within the VAR directory, that is going to be the home of your variable data.
4:18Hence, the name VAR. Pretty much think about data that is ever changing. So data that is growing in size or shrinking in size, data that is not static. So think of things such as logs or perhaps maybe email, whatever it may be. So say, for example, you wanted to see the logs for the booting of your system, where would you go? Well, you would to look within the VAR directory. And then within there, we can see we have this log directory here. We can go into this. So we can see things such as the message right here. That is going to contain all of our kernel messages.
4:50So if I just say cat on that particular file, here is all this kernel information. And if we go on up to the very top, we can actually see the boot process began to kick off. As you can imagine, details such as logging, it's going to be variable. It's going to be changing. That is why it's going to be located within the VAR directory. So those are some of the common system files and directories that we have to understand for the purposes of Linux plus examination. But the reality is, there are even more on the system. Ones that we have to look at with a little bit more detail. The very next one that we're going to be looking at is the dev directory.
5:22And well, that's what we're talking about in the very next Nugget. But for now, I hope this has been informative for you. And I'd like to thank you for viewing.
The Dev Directory
0:12Hey, everyone, and welcome back. Now previously, we talked about some of the main system fails and directories within the file system hierarchy standard. We talked about the boot directory, as well as the etc directory, then the lib directory, and then finally, the var directory. Now, there are more directories within this domain to explore but like I say, they do perhaps require a little bit more attention to detail. And as such, I'm choosing to split them up. The one that we're going to be looking at in this Nugget right here is the dev directory.
0:44This is a super important directory, and the reason why is that this is where your device files are located. What exactly do I mean when I say device files? Basically, if you want your system to be able to talk to some hardware, maybe a keyboard or a USB drive, the system itself is going to use these particular device fails to make that connection happen. Unfortunately, it can't just happen with pure magic. The system is going to lean on and rely on these files to make this work.
1:14If we happen to go to this particular directory right now, we do a cd into the dev directory. If I do an ls, look at all this information that we see right here. So let me give you a breakdown on the types of things that you can expect to see right here. You can expect to see things such as sda. As it transpires on my machine right here, that's virtual machine happens to be running an ARM-based image because I am using Apple Silicon. And as such, this particular convention is not showing up. Instead here, the way it's showing on my system as vda but depending on what you are running at home.
1:50If you're running the ARM-based architecture, you can expect to see VGA, whereas if you happen to be running a regular virtual machine, very, very likely you're going to see this particular convention. But whether you see it or you don't, we do want to understand what that says because that is very, very common within Linux systems. Simply put, when you see sd, you can think of this as a hard drive. Now, and all the systems you would expect to see hd, but the reality is in modern systems are much more likely to see sd. Now, let me tell you what the convention actually is here because it really does tell you about the physical device that is connected.
2:25If you happen to see sda, the sd part tells that you are dealing with a hard drive and the a tells you that you're dealing with the first hard drive on the system. Now, if you happen to have an additional drive attached, you could see that shown up as sdb, b being the second drive. And if you had a third, that would be sdc. Now, that is not all. The way, we see here whereas in my case here, it is substituted for a V as opposed to an S. Notice that actually is a number as well, OK?
2:58So in the case here, I've got vda1, vda2, and vda3. You may have sda1, sda2, and let's just focus on these for now. So straight away, we know sd hard drive, a tells us this is the first hard drive. But look below that is the exact same right here. Both are the first disk. But the crucial thing here is that this one here tells us that says the first partition, and this number two here tells us this is the second partition. So let's imagine you happen to have two disks attached.
3:30The first disk would be disk a, the second one would be disk b. If they were partitions, let's see your hard partition 1 here and partition 2. And let's see, this one here had three partitions, one here and a split here. You have 1, 2, and 3. If I said to you, "Point out to me sdb3." You would know that is the second disk right here and it would be the third partition. That's part right here. You see that? Whereas if I say sda2, you would know that the a tells you is the first disk but as the second partition that I'm talking about.
4:08And' like I say, this information whereby you could derive these insights into your disks and partitions could be found within the dev directory. Now, the reality that is not all. You may notice a whole ton of these tty entries. These are just quite simply device fails denoting either a terminal or a console. If you happen to log in via a terminal, that will spin up as a tty session and it will appear here within the dev directory. Similarly, you may have to have a USB connected, in which case you will see the device file for that particular device and dev/usb.
4:45Now, the dev directory also has some special device files. And these special device files are used for very particular operations. The very first one that I want to draw your attention to is dev null, OK? Now, this as a special device file that is going to allow you to basically discard any information that gets put into it. What do I mean when I say that? Well, take for example, this right here. Let's say I wanted to look at the etc password fail, OK? Now, right now, that opens.
5:15No problem at all, let's clear the stream. Now, let's try one where I would get permission denied. If I tried to open say, for example, the shadow file. And don't worry if you do not know what these failures are quite just yet. Again, we'll talk about that later on within this course, certainly within great detail. But just understand, when I try to open this file, it's saying permission denied. Essentially, I would have to have superuser privileges to read this particular file. Same if I also try to open the sudoers file. Try that one. You see that? Now, if I try to count all these together, if I say cat etc password, and etc shadow, and etc sudoers, if I hit Enter, we open the first file but at the very end, we have these permission denied.
5:57So quite simply, we have two errors within our output. Now, if you happen to be dealing with a lot of data whereby maybe half of it is giving you errors and half of it is valid, being able to easily sort through that data so that you can effectively discard the erroneous data. What you can do is you can invoke that special file dev null. So let me show you what I mean. What I'm going to do is I'm going to take any errors and I can do this using this particular syntax as the number two, and then the forward arrow. And all the two means is that if I happen to have an error, I want to move the error into a particular location and I want to move it into dev null.
6:35If I now do this, look at this right here. Any of the erroneous output has essentially been dumped into the bin and we're only getting the outputs of the commands that we are successful. Now, that's a very, very simple and stripped down example. But honestly, the use of the dev null special file as extremely useful for system administration. And just to close, that also as another file known as /dev/random. This really is a special file that is going to allow you to generate random data that you can give off to applications.
7:08This can be very good if you happen to need some type of random data generator. Perhaps you're invoking some type of encryption, or maybe some random password generator. By invoking this particular special file within the dev directory, you can have easy access to that type of functionality. OK. So that is us for our introduction into the dev directory. Remember, this is where our device files are located. So whether we are connecting to a hard disk, or a USB drive, or a keyboard, these files right here are the files are going to facilitate these types of operations.
7:40So the next directory that we're going to be looking at is the directory. And well, that's what we're talking about in the very next Nugget. So I hope this has been informative for you, and I'd like to thank you for viewing.
The Proc Directory
0:00[AUDIO LOGO] Hey, everyone. And welcome back. Now, previously, we talked about the dev directory. And we learned that this is where our device files are kept. Now, what I want to do is I want to talk to you about the proc directory. How about we dive in and get right to it then? So the very first thing to note about the proc directory is that this as a virtual file system.
0:33And when I see it is a virtual file system, don't confuse that, as some people do, thinking that it doesn't really exist. It absolutely does exist. The difference is that it exists within memory. But basically, when you boot up your system within memory, dynamically on the fly, this directory here is going to be created. Now, the question is, what information does it actually hold? Well, quite simply, this is going to hold information relating to say, for example, you're running processes. It will also have information relating to say, for example, your hardware configuration, as well as providing details about options passed into the kernel.
1:10Now, the first thing that I want to do is to talk to you about these process numbers. So check this out. If I go to my terminal here, and I'm going to type in a command we have not visited yet. Once again, this is still early days. Don't worry about the details too much. Just seat back with a coffee and relax. All I'm going to do is say, pse. Now, when I do this right here, all I'm doing is I'm listing all of the processes on my system here. So if I scroll on up through all of these processes, at the very top, we have the systemd process. And to the left, we have this PID.
1:43This is the process ID. Basically, a numerical value associated with a particular process. Now, see all of these numbers here. If I happen to go into the proc directory, but I'm actually going to see something quite interesting. So let's do that. And we CD into proc. If I do an ls, we can see all of these files here and wait. But look at all of these numbers here in blue. These are all directories, which are associated with those processes that we just saw there.
2:13So within these directories, what we can find are particular files that are going to provide information about that particular process. So within say, for example, this directory here, 15, we will find information about how much memory is being used by process 15, as process 15 opening particular files, so on, and so forth. And, again, if you want to check what that process happens to be, we can say, pse, scroll on up. We recognize the process here as migration, for example. Go into the directory here and find all the correlating information.
2:45Now, one thing to really note here is that, like I say, this here is a file system running in memory. And it is being dynamically updated in real time. Say, for example, I happen to run the ping command. If I just run ping here, and I open up a new window, if I do a pse right now, at the very bottom, we can see here we have the ping process running. And it is associated with process 8229. So now, if I do an ls here, notice in my output here, I actually have this process 8229.
3:16Let me just stop this here, control-C. And I clear the screen. If I do an ls again, notice that particular process is no longer there. 8229 no longer here. That is because that process has stopped. I interrupted it. And because of that, the process ID is not actually appearing within this directory. Again, we can confirm, pse, no ping output at all here. So this directory here as being updated dynamically. Now, like I said, the information is not just about particular process IDs. We also have other information say, for example, our interrupts.
3:50If I do cat interrupts and I scroll on up, this particular file here is really good for locating problems where say, for example device drivers or hardware. Because you can essentially see here, how many interrupts are happening, which processes are causing interrupts. And all of this can essentially be related to performance issues on your machine. Not just that, if I just clear the screen, once again, within the proc directory, I could also get information on, let's say, the file systems here. What I'm seeing here are all of the file systems that are supported by the kernel the time running on my system right now.
4:26So I can see things, such as ext4, fat-based file systems. And once again, we are still very early. We'll talk about what all of these file systems are in an upcoming skill within this course. But understand, if we want to find that list of file systems that are supported by our kernel that we are running right now, we can find out within the proc directory within the files systems. Similarly, let's say, I wanted to get information about the memory usage of my system within the proc directory that will be a file called meminfo.
4:56If I open this up, check this out right here. Let me scroll on up. I can see my total memory. I can see the memory, which I have free, all of the buffering caching, so on, and so forth. All of that is also available within the proc directory. Maybe I want to see some type of information about my networking connections and my networking interfaces, but within the proc directory. We also have another directory known as the net directory. We can see this right here. If I do a CD net, or rather CD net, should I say, for doing ls.
5:26We have all of this information relating to say ipv6 routes, or simple network management protocol or routing information. All of these, once again, within the proc directory. Now, to be honest, there is an absolute ton of information within this particular directory. But for the purposes of the examination, you really want to be remembering that this is a virtual file system holding stuff like kernel information, hardware information, as well as information on those running processes. That is it for our introduction into the proc directory.
5:57We'll get to look at a lot of the information that we've sought here within this directory in a lot more detail later on within this course. But for now, the next thing that I want to talk to you about is the sys directory. And well, that's what we're talking about in the very next Nugget. So I hope this has been informative for you. And I'd like to thank you for viewing.
The Sys Directory
0:00[AUDIO LOGO] Hey, everyone. And welcome back. Now, previously, we talked about the proc directory, which we learned was a virtual file system created in memory. The next file system that I want to talk to you about is the sys file system. Once again, also a virtual file system, also created in memory on the fly.
0:31The question is, what exactly does this sys file system provide us in terms of information? Well, let's talk about it and find out then, shall we? The type of information we're going to find within the sys directory is going to be information relating to kernel modules, as well as hardware and driver information. And like I say, that is all going to be information that we can update on the fly and real time. Now, one thing I should just state as a point of clarification is that the file system itself is actually known as sysfs, so sys file system.
1:03The crucial thing to note here is that sysfs is actually just mounted from and accessible from the sys directory. So a little detail there, but important to understand. So let's go and have a quick peek into this particular directory, shall we? So let's CD into sys after doing ls. As we can see here, we have a number of directories. Now, if we go into the first directory, we're going to block devices. But then here, we can see some loopback information, as well as, in my case here, vda, which happens to be my desk.
1:34And just for posterity, if I just quickly go to the nodes, and I create an Ubuntu system, just give it a very basic setup. So I'll just copy this configuration here. And I will log in. Let's just accept the fingerprint, type in my password. So now, I'm on the cloud-based machine. No longer within my ARM architecture. If I go into the sys directory here, do an ls, if I go in to block devices, ls here, as we can see here, in this case here, as expected, we can see two disks, SDA, the first disk, and SDB.
2:06So any type of hard drives or solid state drives information about those drives will be found within the block directory within the sys directory. Whereas, if I go back out, let's maybe go into, let's say, the kernel directory within sys. Inside of here, we're going to be able to find things such as the kernel version or perhaps the kernel configuration, so on, and so forth. Similarly, if I go back, do an ls, if I go in to say, for example, devices, inside of here, I'm going to be able to find network information, computer information, memory information relating to all the devices that are connected to my system.
2:42So let me just exit out of the cloud right now. Go back to my own virtual machine right here, which I have locally on my computer. Let's maybe go into devices here. If I do an ls, I could go into the system directory. Do an ls here, I can see information relating to memory or CPU. Let's go into the memory directory here. If I do an ls, I can see my block size base. And if I cut this open, I can see the value here, which is a hexadecimal value, which I think, if I recall correctly, correlates to 128 megabytes.
3:14But don't quote me on that. The value itself is not important. The point is as the F, I want to get this type of information, such as memory block size information relating to my device. Well as expected, I can find that information directly within the sys file system. So the key point here to remember is that the sys file system, once again, just like proc, as a virtual file system created a memory and updated on the fly and real time. It's going to contain information relating to kernel modules, hardware such as block devices, devices, which are attached to your system, and information such as power management and the status of your battery.
3:49All of that type of information will be located within the sys directory. So I hope this have been informative for you. And I'd like to thank you for viewing.
FHS User Files and Directories
0:00[AUDIO LOGO] Hey, everyone, and welcome back. Now previously, we had been focused on system files and directories within the file system hierarchy standard. Things like the boot directory or the lab directory. Or more recently, the dev, proc, SAS directories. What I now want to do, though, is to focus our attention more on the directories and files relating to users.
0:34So what exactly are the directories that we are going to focus on within this Nugget right here? Well, for a start, we'll be looking at the home directory, as well as the media directory. And then the mount directory, as well as the root directory. This is the one whereby there can be some confusion. And we'll also look at the TMP directory. So let's first begin by talking about the very first one at the very top here, the very well used home directory. So let's dive in and talk about them.
1:04OK. So if I do CD roots once again, I'm back to the root of the file system. If I go into this home directory right here, within this directory, there is going to be a directory automatically created with my username. So my username, as we can see here within the prompt, is IPvZero. If I do an LS, lo and behold, there is a directory here called IPvZero, after my username. And within that directory here, this is where I am in my home directory.
1:35And I can actually see here, within the prompt, this little tilde sign that actually lets you know that you're in your home directory. Now the purpose of this particular directory, is quite simply, this is your home. This is where you keep your own sample personal files. If I do an LS, we can see things such as documents. So if I've got some personal documents, such as my recipes, .txt. Maybe I've got some super simple but equally delicious pizza recipes, so pepperoni cheese and, I don't know, pizza dough.
2:07Well, I'm always quite lazy and just buy it. But there you go. Nevertheless, if I did happen to have my own recipe, will be storing that within my home directory and such a thing as my documents file. Of course, that is going to make much more sense than have that located in somewhere like, say, the boot directory. Similarly, we can also see within this directory, we have things such as our pictures. So if you happen to store any pictures, that should be a good directory for you. Or if you happen to have saved some videos, once again, this as the location you would want to save there.
2:40Now of course, there is nothing forcing you to follow this particular format. Indeed, if you decide, maybe I don't want to have a video directory, it's just a distraction for me, well, if I so wish, I can remove that. And if I do a listing now, suddenly that directory is gone. And maybe I would rather have a Linux study directory. Trying to be productive after all. The point here is that this is really a fully customizable workspace to meet your own needs. So as we move on, we go back to the roots of the tree. And we do a listing once again.
3:11We can see we have this media directory here. If we go in, we do an LS, we actually see nothing is in this directory. Now that is because this is going to be a location whereby you can mount and access removable media, things like DVDs or USBs, whatever it may be. That is going to be accessible within this particular directory. Now as it transpires, I don't actually have a USB connected to this device. After all, it is just a simple virtual machine. It's not a real machine. But I'm using it any real world way.
3:42But like I say, if you are running Linux in the real world and you do attach some type of USB stick, then the contents of that stick will be available via this particular directory. Now one thing I just want to point out to you, is that it might be a little bit confusing when you hear about having access to things like USB within the media directory because maybe you recall that we talked about a similar concept within the dev directory. Now the key distinction here is that the dev directory is where the device files for these devices are.
4:16So the files that actually facilitate these operations are located there. So if you attach a USB, the way that that can be essentially accessed was because a file was in the dev directory that facilitated that access. But once it has mounted and you actually want to access say, for example, the data on that USB, the media on that USB, the way you actually interact with that drive is going to be in the media directory. Now the next directory I want to show you is really, really similar once again but that has a distinction.
4:49So if we do an LS, we can see we have the mount directory. Now what we were just talking about with the media directory, we're saying how that can mount things like removable media, DVDs, USBs, and so on and so forth. So why on earth would we have a mount directory then? Well, the mount directory here is really for temporary mounts. And it really has a focus on temporarily mounting file systems. So if you happen to attach a file system that was mounted over the network, you would access that network drive via the mount directory.
5:24That is where you would want to mount that particular network share. Or perhaps if you wanted to access an external drive being used as a file system, again, you would want to mount that within the mount directory. Again, like I said, this is a temporary mounting point for file systems. It's going to be much more frequently used by technical people. Whereas the media directory, well, that is more used for the average user on the desktop. Say, for example, accessing media, mounting a DVD and watching it, say, for example. But these two can be quite confusing.
5:54But really try to draw a distinction here. One is really for accessing media. The other is just for temporarily mounting file systems. Now the next one is going to be, yep, maybe another confusing one, is going to be the root directory. Now you can see here, when I try to CD into this directory, it's telling me that the permission is denied. Maybe that will give you a clue as to what this directory is all about. Quite simply, the way we have this home directory here for the user IPvZero, well, the root account, i.e.
6:25the administrator of the system, also has this type of home workspace, so to speak. And the root directory is really just the root user's home directory. So if I want to be able to access this particular directory, what I would have to do would be to become the root user. So if I just log in as the administrator right here, notice now that I am the root user, I can say, who am I. We can see I am the root. If I do CD to take me to my home directory and I do a print working directory, we can see here that I am automatically now in the root directory right here.
6:58Now, this doesn't have the basic skeleton folder layout the way the home directory does, of documents, downloads, so on and so forth. But I as the root user, if I wanted to create such things, then of course, I could do that, no problem at all. I could just say, mkdir documents, do an LS. Suddenly I have that particular directory. So really this is just the workspace here for the root user. So let's go back and log in as my regular accounts. If I do a CD, I go back to my home directory. If I print the working directory, notice now I'm back within home IPvZero because as we see here, I am the user IPvZero once again.
7:32Now the last directory that I want to show you within this Nugget here is, if I go back to the root here and I now go into the TMP directory, now one thing to note here is that the TMP directory is colored a little bit different. Let me tell you this. The TMP directory is there for temporary files. And one of the caveats about this particular directory is that it has really, really relaxed permissions. Many directories, for example, will only allow you to read particular files within them. Some may even allow you to read and write particular files.
8:03But many will not allow you to actually execute particular files within them because of course, that could potentially be dangerous. The temporary directory though, is very, very relaxed in the respect that pretty much anyone can execute file from within this TMP directory. So after the file is located there, you can run it from there. So if I go into this directory here, all we're going to see here are a whole bunch of temporary files. And typically what would happen is that when you happen to reboot the system, the files here within this temporary directory are going to be deleted by particular startup scripts.
8:37It's not always the case, depending on the particular situation. But that is a very general behavior. And just one point to highlight about the potentially dangerous nature of this directory is that because of the relaxed permissions within this folder, this is often a folder utilized by hackers to break into a system. Because once they access this particular directory, they can actually have permission to run all these hacking scripts, such as bash scripts and Python scripts, to effectively attack and gain control of the system.
9:08So you've always got to be aware of that attack vector when managing your Linux system. Okidoke, so that is us for our basic introduction into the user files and directories on the Linux system. The next thing I want to talk to you about are these system binaries and programs. And well, that's what we're talking about in the very next Nugget. So I hope this has been informative for you. And I'd like to thank you for viewing.
FHS System Binaries and Programs
0:12Hey, everyone, and welcome back. Now, previously, we looked at the file system hierarchy standard user files and directories. Now, what you want to do is to focus in on these system binaries and programs within the file system hierarchy standard. So the directories that we're going to focus in on in this Nugget is going to be the bin directory, the opt directory, as well as the sbin, and user directories. So let's dive in and explore them, shall we? So the very first directory that we're going to explore now is going to be that bin directory.
0:43So once again, we go to the roots. If we do an ls, we can see here it resides right here. If I do a cd bin and I do an ls here, you may think the output that you see here is really quite familiar. Let me show you what I mean. If I scroll on up, you might see things such as ls or scrolling or not be a little bit further, you might see things like cp or cat. Or one we looked at earlier, ps. Indeed, what we are actually looking at here are the binary executables needed for our system to operate.
1:15And you may notice that the color of all of the items here looks a little bit different instead of seeing blue for the directory, or white for a file. Instead, here I'm getting a whole bunch of green. That's because these are executable files. So the bin directory has all of these binary executables. But next directory we are going to look at is the opt directory. If I just go into cd, into the root, do an ls. Here is this directory here. Let's go in to see the opt. If I do an ls here, nothing is actually here at the moment. And that's because this is where you're going to find optional, hence the name, software packages that are not required that you could get via third party.
1:53Quite simply, this gives us a nice little space whereby we can isolate these programs from the rest of the system, thus making it really easy for them to be removed again. So if you want to build a third party program from source, this is where you want to be putting those files. Now, the next directory we're going to look at is going to be the sbin directory, which is right here. So if we cd into sbin, this looks really quite familiar. It's very, very similar to the bin directory. We're going to see these binary executables, need default our system to operate. But these are going to be system level binary executables.
2:27And typically, these are going to require privilege escalation, i.e. administrator access to utilize these from the sbin directory. And then lastly, the one we want to look at is the user directory. Now, within the user directory, there's going to be a whole bunch of subdirectories. And these are subdirectories are going to contain executables, much like we saw before as well, as directories for different libraries and documentation. So here's the thing. Remember, we saw our /bin directory, and within there we had all of those bin executables.
3:00Within our user directory, we also have another bin directory. And this is the bin directory used for local user programs. If I go into this directory here user bin this time, do an ls, we're going to see the same type of output that we saw before. But this is going to be, like I say, for local user programs. So again, you expect to see the same type of output if I happen to scroll on up. We can see things like the ls commands the pwd command, so on and so forth. And in fact, when I happen to go on to a system, let's go into my home directory, and I do an ls.
3:34Ultimately, what is happening is that under the hood, what is being executed is this command simply in shorthand. So if I do this right here, we essentially get a listing of the directory once again. Now, the reason why I don't have to specify the full path is because this particular path is set within a path environment variable. And if I just say echo$ same path, what we're going to see here are a whole bunch of directories separated by colons. So you see the first directory here, then the next one, then the next, so on and so forth.
4:05Quite simply, when I issue an ls, Linux automatically is going to check these particular directories looking for an ls executable. And if it finds it, then it's going to call it directly from that. So quite simply, we can just shorthand it and because of that path environment variable, Linus configure where the executable actually resides. So we'll get to make use of these executables in great depth through this course. But for now, that is us for our introduction into these system binaries and programs. So I hope this has been informative for you, and I'd like to thank you for viewing.
Frequently asked questions
What does the Understand Linux Fundamentals lesson cover?
The lesson walks through the Filesystem Hierarchy Standard, starting at the filesystem root and using man hier to look up each top-level directory. It then covers system directories such as /boot, /etc, /lib, and /var, device files in /dev, the /proc and /sys virtual filesystems, and how the PATH environment variable locates system binaries.
How long does the Understand Linux Fundamentals lesson take?
The lesson runs 49 minutes. It is one part of the CompTIA Linux+ (XK0-005) course, which IT Directors and Training Managers should plan at about 32 hours per learner before review time.
How does this lesson fit into CompTIA Linux+ (XK0-005) preparation?
It is the fundamentals starting point the course recommends rolling out first, before storage, networking, security, automation, and troubleshooting. The trainer focuses on the core FHS components a learner needs to understand for the Linux+ examination rather than every directory listed in man hier.
What are /proc and /sys used for on a Linux system?
Both are virtual filesystems created in memory. In /proc, each numbered directory maps to a process ID, and files such as interrupts and filesystems help a team member spot device driver or hardware performance issues and see which filesystems the running kernel supports, while /sys exposes kernel module, hardware, and driver information in real time.
What can a team member do with /dev/null and /dev/random after this lesson?
The learner sees how device files in /dev connect the system to hardware such as disks, USB drives, and keyboards. They also practice discarding erroneous command output to /dev/null and using /dev/random to supply random data for tasks such as encryption or password generation.
Why does the lesson cover directory permissions as a security risk?
The trainer highlights that a directory with relaxed permissions is often used by attackers to run bash or Python scripts and gain control of a system. For an IT Director, this gives every admin on the team a shared awareness of that attack vector from the first lesson of Linux administration.
Team training path
Turn this skill into assignable team training
This free skill is a preview of the courses your team can assign, track, and report on with CBT Nuggets.
Free training library
More free lessons in Linux
Linux
Introduction to LPIC-1
Free lesson from Linux Professional Institute LPIC-1 (101-500 & 102-500) · 49m
Linux
Install and Configure the Apache Web Server in Linux
Free lesson from Everything Linux · 52m
Linux
Monitor & Measure Resources Usage
Free lesson from Linux Professional Institute LPIC-2 (201-450 & 202-450) · 56m
Linux
Introduction to RHCSA
Free lesson from Red Hat Certified System Administrator (RHCSA) Exam EX200 · 52m
Linux
Linux Evolution and Popular Operating Systems
Free lesson from LPI Linux Essentials (010-160) · 52m
Linux
X.509, Web Certificates, and Hashing
Free lesson from Linux Professional Institute Security Essentials (020-100) · 49m
$59
seat / mo, billed annually
