1 00:00:00,000 --> 00:00:04,350 File System Structure and its Description, we have 2 00:00:04,350 --> 00:00:08,310 file system in Linux that is divided into 3 00:00:08,310 --> 00:00:11,190 different directories, and that's something that 4 00:00:11,190 --> 00:00:14,250 we have seen previously as well. So, now I am 5 00:00:14,250 --> 00:00:18,180 going to take some time in this lecture to go over 6 00:00:18,270 --> 00:00:22,650 each file system partition or the folder or a 7 00:00:22,650 --> 00:00:26,040 directory that is set up in Linux, and I will 8 00:00:26,040 --> 00:00:31,140 explain you every directory in Linux file system 9 00:00:31,200 --> 00:00:35,400 and what is it used for. So, I have listed down 10 00:00:35,430 --> 00:00:38,166 all the directories and I will go over them, 11 00:00:38,166 --> 00:00:43,140 one by one based on how important they are. So 12 00:00:43,140 --> 00:00:45,660 the first one and the most important one that we 13 00:00:45,660 --> 00:00:50,100 have in the list is slash boot. Slash boot is the 14 00:00:50,100 --> 00:00:53,550 file or is the directory that contains files used 15 00:00:53,550 --> 00:00:57,480 for boot loader or the file that is in there is a 16 00:00:57,480 --> 00:01:01,350 grub.cfg, your configuration file. What 17 00:01:01,350 --> 00:01:04,260 happenes is every time your system boots up, the 18 00:01:04,260 --> 00:01:07,080 first thing the operating system that needs to 19 00:01:07,080 --> 00:01:10,800 boot up the system looks for slash boot and that 20 00:01:10,800 --> 00:01:14,610 is somehow hard coded in the disk, that you start 21 00:01:14,610 --> 00:01:17,760 up, go into slash boot, and you will find what you 22 00:01:17,760 --> 00:01:20,280 what operating system you need to start. There is 23 00:01:20,280 --> 00:01:23,970 old operating system or a new one or upgraded 24 00:01:23,970 --> 00:01:27,060 version. So it goes into the slash boot file, and 25 00:01:27,060 --> 00:01:29,940 it looks into it. By the way I will go over each 26 00:01:29,940 --> 00:01:33,510 one of the directory in my Linux system and I'll 27 00:01:33,510 --> 00:01:36,630 show you exactly what inside of each directory. 28 00:01:36,810 --> 00:01:41,610 Second one we have slash root, it is the root user 29 00:01:41,610 --> 00:01:45,750 home directory. Please remember it is not the same 30 00:01:45,750 --> 00:01:49,470 as slash. A lot of times people confuse slash 31 00:01:49,500 --> 00:01:53,910 which is also known as a root, but it is not 32 00:01:53,910 --> 00:01:57,990 actually slash root. So root when you log into a 33 00:01:57,990 --> 00:02:01,710 system or Linux system as root, and you do pwd, you 34 00:02:01,710 --> 00:02:05,280 will see you will be in a slash root, not just 35 00:02:05,310 --> 00:02:10,080 slash. Then we have slash dev directory. This is a 36 00:02:10,080 --> 00:02:14,310 systems device such as a disk, a CD ROM, speakers, 37 00:02:14,310 --> 00:02:17,490 flash drive, keyboard, any of those peripheral 38 00:02:17,490 --> 00:02:21,300 devices that are attached to your Linux system. 39 00:02:21,540 --> 00:02:25,800 They are created as a file as well and they will 40 00:02:25,800 --> 00:02:30,900 show up in a slash dev directory. Going and moving 41 00:02:30,900 --> 00:02:34,470 forward is the next one is slash etc, it is 42 00:02:34,470 --> 00:02:38,730 also one of the most important directory in Linux 43 00:02:38,730 --> 00:02:43,140 file system. It has all the configuration file. If 44 00:02:43,140 --> 00:02:47,970 you are running Sendmail, NFS, NTP, or any 45 00:02:47,970 --> 00:02:51,750 kind of application that actually runs on top of 46 00:02:51,750 --> 00:02:54,570 your Linux system, or that comes with a Linux 47 00:02:54,570 --> 00:02:58,830 system. All those configuration files are located 48 00:02:58,890 --> 00:03:02,460 in slash etc. If I wanted to modify something on 49 00:03:02,460 --> 00:03:06,630 let's say DNS, I will go into slash etc slash name.conf 50 00:03:06,630 --> 00:03:09,717 file. If I want to modify something in the Sendmail, 51 00:03:09,717 --> 00:03:14,906 I will go into etc, the mail, and sendmal.cnf, 52 00:03:14,906 --> 00:03:17,820 or that type of configuration file. So just 53 00:03:17,820 --> 00:03:20,760 remember that anytime you're making change in 54 00:03:20,760 --> 00:03:24,420 slash etc to any file inside of this directory 55 00:03:24,420 --> 00:03:28,260 please make sure you make a backup first of that 56 00:03:28,260 --> 00:03:31,680 file before you modify the configuration file. 57 00:03:32,220 --> 00:03:35,160 Then we have slash bin, slash bin in the newer 58 00:03:35,160 --> 00:03:38,970 version has been changed to slash user slash bin. 59 00:03:39,180 --> 00:03:44,610 It is like a linked to slash user slash bin and it 60 00:03:44,610 --> 00:03:48,150 is actually the directory where we have the 61 00:03:48,150 --> 00:03:52,110 commands that are used by everyday user commands 62 00:03:52,110 --> 00:03:55,740 like ls, pwd, these type of command, all of them 63 00:03:55,770 --> 00:03:59,580 are in slash user slash bin directory. Then we 64 00:03:59,580 --> 00:04:03,600 have another directory called slash sbin which is 65 00:04:03,600 --> 00:04:07,410 pointing or linked to slash user slash bin. This 66 00:04:07,440 --> 00:04:10,890 is a system slash file system commands. Those are 67 00:04:10,890 --> 00:04:12,900 the type of commands that you really need for 68 00:04:12,900 --> 00:04:15,600 system type of purposes. If you want to extend 69 00:04:15,600 --> 00:04:18,240 your file system or configure your file system 70 00:04:18,450 --> 00:04:22,110 that will take a look again, in our when I bring 71 00:04:22,110 --> 00:04:25,920 up my Linux machine, slash opt. slash opt is used 72 00:04:25,920 --> 00:04:29,280 for optional add-on application. It is not the 73 00:04:29,280 --> 00:04:33,840 application for operating system apps like NTP, 74 00:04:34,110 --> 00:04:36,840 DNS, those are the application that is actually 75 00:04:36,840 --> 00:04:41,430 come with the operating system. This slash opt is 76 00:04:41,430 --> 00:04:43,980 not used for those type of application that is 77 00:04:43,980 --> 00:04:47,070 used for third party application. Let's say if you 78 00:04:47,070 --> 00:04:50,370 are installing, let's say Oracle or some other kind 79 00:04:50,370 --> 00:04:53,340 of application or SCP, those are applications 80 00:04:53,340 --> 00:04:56,160 usually and most of the time are installed in 81 00:04:56,160 --> 00:04:57,360 slash opt. 82 00:04:58,650 --> 00:05:02,040 slash proc is the directory that is used 83 00:05:02,340 --> 00:05:05,430 in create files for all the running processes. 84 00:05:05,700 --> 00:05:08,730 Please remember when you shut down your Linux 85 00:05:08,730 --> 00:05:11,370 operating system there will be nothing in slash 86 00:05:11,370 --> 00:05:14,880 proc it will be empty. So, the kernel, which I 87 00:05:14,880 --> 00:05:17,190 will explain you later on what kernel is, but 88 00:05:17,190 --> 00:05:20,430 there is a program kernel in Linux that 89 00:05:20,430 --> 00:05:23,580 actually creates all these files for all the 90 00:05:23,580 --> 00:05:25,830 running programs in that directory once system 91 00:05:25,830 --> 00:05:30,780 shuts down, all those files go away. lib, which is 92 00:05:30,780 --> 00:05:35,250 now pointing to usr/lib, it's 93 00:05:35,250 --> 00:05:37,830 a location where all the C programming library 94 00:05:37,830 --> 00:05:41,100 files, and those files are needed for commands and 95 00:05:41,100 --> 00:05:43,710 applications. Meaning if you are running a 96 00:05:43,710 --> 00:05:47,460 command, let's say pwd or ls, all those commands 97 00:05:47,490 --> 00:05:52,260 actually do have a libraries attached to it that 98 00:05:52,260 --> 00:05:55,980 they could go and look for. And that's how these 99 00:05:55,980 --> 00:05:58,680 programs are run because they are written in C and 100 00:05:58,680 --> 00:06:04,170 C++. If you wanted to know which 101 00:06:04,170 --> 00:06:08,160 command is used, and sorry, which library file 102 00:06:08,160 --> 00:06:10,470 is used for which command, you could use this 103 00:06:10,470 --> 00:06:15,210 command strace -e open, like pwd is the 104 00:06:15,210 --> 00:06:17,880 command. That next one we have slash tmp 105 00:06:17,880 --> 00:06:20,430 directory, the directory that is used for 106 00:06:20,430 --> 00:06:23,220 temporary files. It has no significance 107 00:06:23,220 --> 00:06:26,010 whatsoever. But you could just if you want to 108 00:06:26,010 --> 00:06:28,260 create a file, a temporary file that you think you 109 00:06:28,260 --> 00:06:31,440 will delete later, you could create that slash 110 00:06:31,440 --> 00:06:35,070 tmp directory. Slash home directory is used for 111 00:06:35,070 --> 00:06:38,970 regular users while creating a regular account on a 112 00:06:38,970 --> 00:06:41,760 Linux file system, let's say iafzal, my home 113 00:06:41,760 --> 00:06:45,210 directory will be created in slash home. The next 114 00:06:45,210 --> 00:06:48,810 one we have is slash var. slash var is used for 115 00:06:48,810 --> 00:06:51,930 system logs. Every time your your operating system 116 00:06:51,930 --> 00:06:56,460 writes some output or some logs, all those logs or 117 00:06:56,460 --> 00:06:59,430 its application logs will always go into slash 118 00:06:59,430 --> 00:07:02,370 var. So if you are troubleshooting issues, you can 119 00:07:02,370 --> 00:07:07,080 always go into slash war log and other directories 120 00:07:07,080 --> 00:07:09,750 where you will find information about a specific 121 00:07:10,080 --> 00:07:12,810 application or if something going wrong with it. 122 00:07:13,830 --> 00:07:16,200 Then we have slash run, this is where the 123 00:07:16,200 --> 00:07:19,380 system's daemon starts up on very early stages. For 124 00:07:19,380 --> 00:07:22,710 example, systemd and udev to store temporary 125 00:07:22,710 --> 00:07:26,970 runtime files like pid, or process id files, and 126 00:07:26,970 --> 00:07:30,720 again, this will go away if the system is shut 127 00:07:30,720 --> 00:07:33,960 down, it just stores those process id and keeps 128 00:07:33,960 --> 00:07:39,240 track of it. Slash mount is used to mount external 129 00:07:39,240 --> 00:07:42,030 file system. If there is nothing, if nothing is 130 00:07:42,030 --> 00:07:45,000 mounted on your existing file system, then you 131 00:07:45,000 --> 00:07:48,180 could use that slash mount to create another 132 00:07:48,210 --> 00:07:51,420 subdirectory and mount any external NFS file 133 00:07:51,420 --> 00:07:58,050 system to it. Slash media is used for CD ROMs. If 134 00:07:58,050 --> 00:08:02,490 your system has a CD ROM drive and you put a CD 135 00:08:02,490 --> 00:08:07,680 ROM inside of it, then you close the tray. That CD 136 00:08:07,680 --> 00:08:11,040 ROM will be mounted under slash media. If you're 137 00:08:11,040 --> 00:08:14,520 using a virtual machine, you map the virtual drive 138 00:08:14,820 --> 00:08:18,540 to your virtual machine, that virtual ISO image 139 00:08:18,570 --> 00:08:22,830 will be shown under slash media CD ROM. So that's 140 00:08:22,830 --> 00:08:25,410 the list of all the directories that we have that 141 00:08:25,410 --> 00:08:27,930 support system structure and his description. And 142 00:08:27,930 --> 00:08:30,510 now I'm quickly gonna go into my Linux system and 143 00:08:30,510 --> 00:08:33,808 I'll show you exactly each one of them and how it 144 00:08:33,808 --> 00:08:41,280 is set up. So I am logged in as whoami, I'll do 145 00:08:41,280 --> 00:08:45,000 root, and I'll cd into slash, and I will do ls 146 00:08:45,000 --> 00:08:48,960 -ltr or ls -l, and you'll see all these 147 00:08:49,080 --> 00:08:52,500 directories that I have just covered. So first one 148 00:08:52,500 --> 00:08:55,650 I have is boot ,and if you notice in the boot there 149 00:08:55,650 --> 00:08:59,970 is these two directories grub and grub2. If I go 150 00:08:59,970 --> 00:09:04,560 into grub or grub2, let's go to grub2 and do 151 00:09:04,560 --> 00:09:07,680 ls -ltr, you'll see there is grub 152 00:09:07,680 --> 00:09:09,780 configuration file. This is the file that's 153 00:09:09,780 --> 00:09:11,760 telling the system which operating systems to 154 00:09:11,760 --> 00:09:14,310 start, or which version of operating systems to 155 00:09:14,310 --> 00:09:16,020 start. Let's go to slash root. 156 00:09:17,639 --> 00:09:21,059 This is the root home directory. If I just hit cd, 157 00:09:21,059 --> 00:09:24,239 and hit enter, and do pwd, this is the root home 158 00:09:24,239 --> 00:09:26,789 directory. There's nothing much in there. It's 159 00:09:26,789 --> 00:09:29,819 just its own Desktop, Document probably it has all 160 00:09:29,819 --> 00:09:32,489 of them are empty, nothing is in there. Then I 161 00:09:32,489 --> 00:09:36,689 will go to slash etc. This is the directory 162 00:09:36,689 --> 00:09:39,509 which has all the configuration file, most of the 163 00:09:39,509 --> 00:09:41,819 files that you're going to see in the in this 164 00:09:41,939 --> 00:09:44,759 directory or the subdirectories all of them will 165 00:09:44,759 --> 00:09:48,569 have conf. So it means it has configuration file 166 00:09:48,899 --> 00:09:51,869 going to slash bin which is pointing to use a bin. 167 00:09:52,049 --> 00:09:55,559 It has all the commands that we use, everyday 168 00:09:55,559 --> 00:09:58,619 command to actually talk to the operating system. 169 00:09:58,619 --> 00:10:01,619 Same thing with sbin This one has all the ones 170 00:10:01,619 --> 00:10:04,259 that deals primarily within your file system, 171 00:10:04,469 --> 00:10:08,519 disks, and extending the file systems. Then we have 172 00:10:08,549 --> 00:10:12,599 opt, you do ls -l. And you will see this is 173 00:10:12,599 --> 00:10:14,879 the one that is used for third party application. 174 00:10:14,879 --> 00:10:17,429 right now it only had like rh, which stands for 175 00:10:17,429 --> 00:10:21,269 Red Hat, nothing else. Then we have proc is the 176 00:10:21,269 --> 00:10:24,119 one that runs all the running programs 177 00:10:24,119 --> 00:10:27,359 temporarily, it is not the actual file that will 178 00:10:27,359 --> 00:10:31,349 stay on the disk. We have next one library, and 179 00:10:31,349 --> 00:10:34,469 library has all the library files that are needed 180 00:10:34,709 --> 00:10:38,429 to run a simple command. Next one, we have slash 181 00:10:38,429 --> 00:10:41,909 tmp, and slash tmp, you see all these are 182 00:10:41,909 --> 00:10:44,339 temporary files, you delete them, you create new 183 00:10:44,339 --> 00:10:47,549 files, it doesn't really matter. It's just a 184 00:10:47,549 --> 00:10:51,359 scratch space that you could put your files on. 185 00:10:51,629 --> 00:10:54,449 Then you have slash home. Slash home is for the 186 00:10:54,449 --> 00:10:57,839 users like I have my user here, I have another user 187 00:10:57,839 --> 00:11:02,099 called seinfeld, this is the home directory. Then 188 00:11:02,099 --> 00:11:06,149 the next one is slash var. Slash var is used for 189 00:11:06,179 --> 00:11:11,549 all the logs that are created in your system. So 190 00:11:11,549 --> 00:11:15,089 if you, primarily the main log is slash var slash 191 00:11:15,089 --> 00:11:17,849 log, and this is where all the logs are created, 192 00:11:17,849 --> 00:11:19,859 if something goes wrong with the system, this is 193 00:11:19,859 --> 00:11:22,619 where you have to come in. By the way, every one 194 00:11:22,619 --> 00:11:25,349 of these that I'm going through, I will go through again 195 00:11:25,349 --> 00:11:28,319 later on, and you will get more and more familiar 196 00:11:28,499 --> 00:11:32,579 with these file systems and it's directories, and 197 00:11:32,579 --> 00:11:35,639 all the commands that I'm running on. Then the 198 00:11:35,639 --> 00:11:39,059 next one we have slash run, this is the one that 199 00:11:39,059 --> 00:11:42,419 that runs the system daemons very early in the 200 00:11:42,419 --> 00:11:45,539 stages and is a temporary files. The next one we 201 00:11:45,539 --> 00:11:49,019 have mnt, this has probably nothing because I do 202 00:11:49,019 --> 00:11:52,709 not have any external file system mounted on my 203 00:11:52,739 --> 00:11:56,579 disk file, on my this computer. So if I mount it, I 204 00:11:56,579 --> 00:11:59,279 will use a command mount to file it and usually it 205 00:11:59,279 --> 00:12:01,709 gets mounted in slash mnt, because you have to 206 00:12:01,709 --> 00:12:06,059 specify it and that's where it goes. The last one 207 00:12:06,059 --> 00:12:10,109 is, we have slash media is, this is where if you had a 208 00:12:10,109 --> 00:12:13,979 CD Mount, CD ROM attached to your system, this is 209 00:12:13,979 --> 00:12:18,389 where it will go. Anyway, this is what I want to 210 00:12:18,389 --> 00:12:20,099 cover in the file system structure and 211 00:12:20,099 --> 00:12:23,519 description. I really hope that this lecture 212 00:12:23,519 --> 00:12:27,269 covers everything in terms of the file system and 213 00:12:27,269 --> 00:12:28,925 structure. Thank you. 214 00:12:28,925 --> 00:12:30,784 [No audio]