1 00:00:00,000 --> 00:00:11,900 In this video, you'll learn about the directories dev, sys, and proc, pseudo-file systems that 2 00:00:11,900 --> 00:00:17,700 help you in tracing what is going on in hardware and kernel-related events. 3 00:00:17,700 --> 00:00:20,180 So what is going on in these pseudo-file systems? 4 00:00:20,180 --> 00:00:25,180 Well, they exist in memory only and not on disk, and they are used by the kernel to keep 5 00:00:25,180 --> 00:00:28,420 track of what is happening on your system. 6 00:00:28,420 --> 00:00:32,060 Slash proc is for kernel runtime information and tunables. 7 00:00:32,060 --> 00:00:37,419 You can get a lot of information out of slash proc, and you can also tweak your kernel by 8 00:00:37,419 --> 00:00:41,220 changing parameters in the slash proc directory. 9 00:00:41,220 --> 00:00:45,139 Slash sys is used for hardware-related information. 10 00:00:45,139 --> 00:00:48,860 And slash dev is used to create the device nodes. 11 00:00:48,860 --> 00:00:52,259 Let's have a quick look so that you understand what is going on. 12 00:00:52,259 --> 00:00:58,740 So when we use mount, pipe, grab, proc, there you can see that this magical mount proc on 13 00:00:58,740 --> 00:01:02,459 slash proc type proc, so proc, proc, proc is mounted. 14 00:01:02,459 --> 00:01:07,220 So the device, it's not really a device, it's a kernel interface proc, which is mounted 15 00:01:07,220 --> 00:01:11,500 on the directory proc, and the type is proc. 16 00:01:11,500 --> 00:01:17,379 And that makes this directory special, so special that different rules apply. 17 00:01:17,379 --> 00:01:23,739 You cannot open the files in here in editors, but you can check what is going on for more 18 00:01:23,739 --> 00:01:24,739 information. 19 00:01:24,739 --> 00:01:31,139 Use, for instance, cat on CPU info to get information on your CPU. 20 00:01:31,139 --> 00:01:35,980 Use cat on modules to get information about kernel modules that are currently loaded. 21 00:01:35,980 --> 00:01:40,580 And in case you are thinking, hey, this sounds familiar, well, it sounds familiar because 22 00:01:40,580 --> 00:01:45,980 lsmod is the user interface to the same information. 23 00:01:45,980 --> 00:01:52,180 You should remember that slash proc sys were never created as an easy user interface. 24 00:01:52,180 --> 00:01:59,339 As a user, you normally use tools to get information about what is going on in these file systems. 25 00:01:59,339 --> 00:02:04,379 Apart from the status files that you see in black on the right in the file listing in 26 00:02:04,379 --> 00:02:08,979 slash proc, there are PID files, these are the numbers to the left. 27 00:02:08,979 --> 00:02:14,059 Every process has a PID file in which you can get process information. 28 00:02:14,059 --> 00:02:18,899 And there is also proc sys, which can be used for kernel optimization. 29 00:02:18,899 --> 00:02:24,979 As this section is about hardware and drivers, we are mainly interested in the status files 30 00:02:24,979 --> 00:02:27,860 that you can see on the right. 31 00:02:27,860 --> 00:02:30,699 Now let's talk about sys. 32 00:02:30,699 --> 00:02:33,740 Sys is also one of these pseudo file systems. 33 00:02:33,740 --> 00:02:41,740 So when I use mount pipe grab sys, we can see sysfs is mounted on slash sys, and the 34 00:02:41,740 --> 00:02:44,460 type is sysfs. 35 00:02:44,460 --> 00:02:46,660 So it's in memory, it's not on disk. 36 00:02:46,660 --> 00:02:50,899 And here you find different interfaces that tell you what is going on. 37 00:02:50,899 --> 00:02:56,660 For instance, there is sysmodule, and in sysmodule, you will find directories for all the different 38 00:02:56,660 --> 00:03:00,660 modules that are used on your system. 39 00:03:00,660 --> 00:03:06,779 Let's check out E1000E, for instance, which is the module that is used to address your 40 00:03:06,779 --> 00:03:08,139 network. 41 00:03:08,139 --> 00:03:11,779 So in this directory, we can see a parameters directory. 42 00:03:11,779 --> 00:03:14,259 And in the parameters directory, look at that. 43 00:03:14,259 --> 00:03:20,259 We have a copy break parameter, which is set to the value of 256. 44 00:03:20,259 --> 00:03:25,820 Now what you find in the module directories is really dependent on the driver that is 45 00:03:25,820 --> 00:03:26,820 involved. 46 00:03:26,820 --> 00:03:29,699 Sometimes it's useful information. 47 00:03:29,699 --> 00:03:35,020 Sometimes, as we've seen before for the CD-ROM module, it's rather disappointing. 48 00:03:35,020 --> 00:03:38,460 Another one that I like is in sysbus. 49 00:03:38,460 --> 00:03:42,300 We have CPU, and in CPU, you have devices. 50 00:03:42,300 --> 00:03:46,259 And there you can see a CPU0 and a CPU1. 51 00:03:46,259 --> 00:03:54,899 Right now, when I use lscpupipeless for restricting the output, I can see there are two CPUs. 52 00:03:54,899 --> 00:04:02,380 Now when we use ls in CPU1, you can see that there is this online file. 53 00:04:02,380 --> 00:04:04,539 And what is in this online file? 54 00:04:04,539 --> 00:04:07,380 Well, let's check it out. 55 00:04:07,380 --> 00:04:08,940 It has a 1. 56 00:04:08,940 --> 00:04:10,139 You know what I'm going to do? 57 00:04:10,139 --> 00:04:17,339 I'm going to echo 0 into CPU1 slash online. 58 00:04:17,339 --> 00:04:21,940 This is a rule that applies for everything that you find in PROC and in sys. 59 00:04:21,940 --> 00:04:24,339 You cannot open these cells in an editor. 60 00:04:24,339 --> 00:04:28,500 If you want to change the content, you need to echo the new value into the file just the 61 00:04:28,500 --> 00:04:30,779 way I'm doing it right here. 62 00:04:30,779 --> 00:04:31,779 And what is the result? 63 00:04:31,899 --> 00:04:39,619 Well, the result is that lscpu is now showing me two CPUs, but only one is online, and the 64 00:04:39,619 --> 00:04:41,420 other one is offline. 65 00:04:41,420 --> 00:04:42,739 That's cool, isn't it? 66 00:04:42,739 --> 00:04:48,420 If temporarily, for whatever reason, you need to offline a CPU, this is how you can do it. 67 00:04:48,420 --> 00:04:53,179 I'm onlining it again because I don't want it to be offline. 68 00:04:53,179 --> 00:04:58,019 Final directory, you have probably already worked with it, is the dev directory. 69 00:04:58,019 --> 00:05:01,779 The dev directory is where device nodes are created. 70 00:05:01,779 --> 00:05:08,579 And these device nodes allow users to interface the devices on your system. 71 00:05:08,579 --> 00:05:11,739 That is what is happening where you're mounting devices, for instance.