1 00:00:00,000 --> 00:00:02,060 All right, thank you all for your patience. 2 00:00:02,060 --> 00:00:03,980 We are about to officially start. 3 00:00:05,060 --> 00:00:07,880 Good afternoon slash morning. 4 00:00:07,880 --> 00:00:26,360 It is an honor to introduce DJ Davis, a seasoned IT professional whose career began on IBM mainframes and mid-range systems and expanded to encompass systems engineering, network design, and information security. 5 00:00:26,360 --> 00:00:34,080 DJ holds a bachelor's and a master's degree in business information systems and currently works in the Washington, D.C. 6 00:00:34,080 --> 00:00:38,570 area helping others navigate complex IT ecosystems. 7 00:00:39,240 --> 00:00:50,980 With decades of experience and a passion for mentoring, DJ has made it his mission to reduce the intimidation factor that often surrounds Linux. 8 00:00:51,480 --> 00:01:02,100 His talk today, Let's Lose the Shock, Mystery of Linux, offers a pain-free introduction to Linux and compares his features to those of Microsoft Windows. 9 00:01:02,100 --> 00:01:07,020 If you ever felt hesitant to dive into the Linux world, this is your chance to change that. 10 00:01:07,160 --> 00:01:09,880 Please join me in welcoming DJ Davis. 11 00:01:20,300 --> 00:01:21,900 Awesome, welcome. 12 00:01:22,460 --> 00:01:24,020 Hey, George. 13 00:01:32,210 --> 00:01:33,110 Well , welcome. 14 00:01:33,290 --> 00:01:38,770 Thank you, everyone, for coming to the Blacks in Cyber sessions and presentations. 15 00:01:38,770 --> 00:01:43,110 And thanks for coming to DEF CON because, you know, we have a lot of fun here. 16 00:01:43,190 --> 00:01:49,230 And hopefully we'll have a lot of fun today as we lose the shock value of Linux. 17 00:01:49,230 --> 00:01:50,730 Are y'all ready to have some fun? 18 00:01:50,910 --> 00:01:52,530 All right, all right, all right. 19 00:01:52,650 --> 00:01:56,250 So let's get started into this. 20 00:01:56,250 --> 00:02:00,010 I'll tell you, well, we see the objectives that we have for this. 21 00:02:00,150 --> 00:02:02,590 So, you know, this is an overview awareness. 22 00:02:02,590 --> 00:02:05,050 We're not going to go into all commands and that kind of stuff. 23 00:02:05,050 --> 00:02:06,090 We're not going to be boring. 24 00:02:06,090 --> 00:02:14,610 But, you know, we're going to talk about the difference, you know, between Microsoft Windows and Linux and what have you. 25 00:02:14,610 --> 00:02:18,190 And look into a few of the features and things of this. 26 00:02:19,310 --> 00:02:22,170 So this is our game plan for today. 27 00:02:22,170 --> 00:02:24,990 We're not going to go heavy into comparing distributions. 28 00:02:24,990 --> 00:02:27,630 Let's say that all of the distributions are good. 29 00:02:27,630 --> 00:02:31,130 You know, you pick the one that you like and then you pick another and another. 30 00:02:31,130 --> 00:02:33,190 Have a lot of fun with this. 31 00:02:33,270 --> 00:02:38,510 So we're going to have installing Linux in the appendix. 32 00:02:38,510 --> 00:02:41,170 You'll be able to go there and see that. 33 00:02:41,250 --> 00:02:44,370 And this slide deck will be on GitHub. 34 00:02:44,370 --> 00:02:46,330 So it's there for you. 35 00:02:46,330 --> 00:02:49,510 Maybe we'll see if we can hold the questions until the end of this. 36 00:02:49,510 --> 00:02:51,130 Just keep this moving. 37 00:02:51,130 --> 00:02:55,370 And my usual disclaimer is that this is not affiliated with work. 38 00:02:55,370 --> 00:02:56,870 You know, these are my ideas. 39 00:02:56,950 --> 00:03:01,190 However, you know, work is like fine, cool with me being here. 40 00:03:03,130 --> 00:03:05,070 You heard a little bit about my background. 41 00:03:05,070 --> 00:03:06,650 We're not going to spend much time with this. 42 00:03:06,650 --> 00:03:09,770 But, you know, just in different areas of computing, whatnot. 43 00:03:09,770 --> 00:03:15,310 And currently, you know, I work in IT security in that sector. 44 00:03:15,310 --> 00:03:16,670 Lots of fun there. 45 00:03:16,670 --> 00:03:19,750 My alma mater, VCU, go Rams. 46 00:03:20,350 --> 00:03:21,420 Pretty good school. 47 00:03:22,850 --> 00:03:27,730 So there are a lot of reasons to learn and to use Linux. 48 00:03:27,730 --> 00:03:29,770 So a lot of them are listed here. 49 00:03:29,870 --> 00:03:34,310 I'll just focus on a few toward the bottom of this. 50 00:03:34,410 --> 00:03:39,490 It's great for learning about, you know, how computers work and using different kinds of languages. 51 00:03:39,490 --> 00:03:43,770 You know, on a small machine, you can load a whole bunch of languages. 52 00:03:43,870 --> 00:03:45,010 I do. 53 00:03:45,010 --> 00:03:53,910 So it's a great operating system to see how, you know, things work into detail. 54 00:03:53,910 --> 00:03:56,410 We'll have a little bit of detail here. 55 00:03:56,410 --> 00:03:59,290 It's good for hardware and software hacking. 56 00:03:59,290 --> 00:04:02,510 So pretty soon, if you're not doing that, you will be. 57 00:04:02,770 --> 00:04:05,670 Linux has a rich set of commands. 58 00:04:05,670 --> 00:04:06,730 I love some of the commands. 59 00:04:06,730 --> 00:04:08,530 I mentioned DD and grep. 60 00:04:08,530 --> 00:04:13,550 For no reason other than that, I think it's a good reason to use Linux. 61 00:04:13,550 --> 00:04:22,950 And essentially, it's a very stable, reliable, and powerful OS that is like a free version of Unix. 62 00:04:23,790 --> 00:04:25,190 Unix, did I say? 63 00:04:25,190 --> 00:04:27,310 So what's special about Unix? 64 00:04:27,910 --> 00:04:31,330 Unix gets into, you know, why Linux is around. 65 00:04:31,330 --> 00:04:42,690 So Unix was the first portable, and that's an interesting word, portable operating system, and portable means to copy it from one place to somewhere else. 66 00:04:42,690 --> 00:04:48,190 That was the first operating system that came out, and they were able to do that with. 67 00:04:48,190 --> 00:04:50,590 There's a modular design. 68 00:04:50,970 --> 00:04:52,950 That's pretty good for several reasons. 69 00:04:52,950 --> 00:04:57,310 And Linux, or Unix, started with inter-process communication. 70 00:04:57,370 --> 00:05:02,730 Microsoft uses this too, because if you've ever used a command prompt, you use that pipe thing. 71 00:05:02,730 --> 00:05:07,650 Yeah, Microsoft borrowed that from Unix at the time. 72 00:05:07,830 --> 00:05:11,490 You have input and output redirection. 73 00:05:11,490 --> 00:05:15,330 We see that less than, greater than, sign, those types of things. 74 00:05:15,490 --> 00:05:20,290 And there are three files that are opened automatically for each process. 75 00:05:20,290 --> 00:05:23,830 Standard in, standard out, and standard error. 76 00:05:23,830 --> 00:05:27,790 Okay, so this is a partial list of Linux distributions. 77 00:05:27,790 --> 00:05:29,750 You might see your favorite one on the list. 78 00:05:29,750 --> 00:05:32,850 You know, pick any of these or pick other ones. 79 00:05:33,850 --> 00:05:40,310 So, some differences between the commands of Linux and Microsoft. 80 00:05:40,310 --> 00:05:45,690 Yeah, the green Linux shows somewhat on this slide. 81 00:05:46,550 --> 00:05:55,070 But, so basically, we have the clear, C-L-E-A-R, for clearing the screen, versus the C-L-S. 82 00:05:55,070 --> 00:06:01,150 You know, you grow up on that, and you get used to that in Microsoft, the C-L-S. 83 00:06:01,190 --> 00:06:04,230 How we separate parts of a file. 84 00:06:04,230 --> 00:06:07,570 Linux uses the forward slash. 85 00:06:07,570 --> 00:06:10,750 Microsoft uses the backslash. 86 00:06:10,750 --> 00:06:14,450 Then there is that fun thing about null versus null. 87 00:06:14,450 --> 00:06:23,990 It's, you know, N-U-L on Microsoft, and it's dev or device null, N-U-L-L, for Linux. 88 00:06:24,310 --> 00:06:29,010 There are some other differences in this command, in these commands, as you see here. 89 00:06:29,470 --> 00:06:32,810 You know, just how you do different things. 90 00:06:32,810 --> 00:06:37,710 Some of these, the commands might be the same, but the operation might be a little different. 91 00:06:37,710 --> 00:06:40,790 For example, changing a directory CD. 92 00:06:41,670 --> 00:06:47,890 That can work a little bit differently in both of those. 93 00:06:49,310 --> 00:06:56,290 Linux does have a live distribution, and you can run that off of a USB. 94 00:06:56,750 --> 00:07:00,130 I don't think you can do that that often with Microsoft. 95 00:07:00,130 --> 00:07:06,690 Although they do have some type of third-party thing that you can get, buy, or what have you. 96 00:07:06,770 --> 00:07:11,770 One nice thing that Microsoft does have is the pause command. 97 00:07:12,890 --> 00:07:18,870 And on here, we show how you would implement that in Linux. 98 00:07:18,870 --> 00:07:21,390 You know, you use the read command and a few options. 99 00:07:21,390 --> 00:07:24,830 That's here on the slide, and these would be, you know, available. 100 00:07:24,830 --> 00:07:32,710 There are other differences in things, you know, between the two operating systems as we see here. 101 00:07:32,710 --> 00:07:36,270 In Linux, you tend to work more with the command line. 102 00:07:36,270 --> 00:07:41,050 You tend to work more with the GUI in Microsoft. 103 00:07:41,850 --> 00:07:45,950 Linux has a lot of free languages and things that are available. 104 00:07:45,950 --> 00:07:47,430 Not so much. 105 00:07:47,430 --> 00:07:52,090 Well, you do have some in Microsoft. 106 00:07:52,970 --> 00:07:56,430 And so that support is getting a lot better. 107 00:07:58,030 --> 00:08:06,270 Scripting is a little bit different as well, because you generally script with Bash in Linux, but you can script with other things as well. 108 00:08:06,270 --> 00:08:15,610 Microsoft is going to be, you know, using the PowerShell or using the command prompt. 109 00:08:16,210 --> 00:08:17,780 Some other differences. 110 00:08:17,780 --> 00:08:26,760 The super user account in Linux's root in Microsoft is administrator. 111 00:08:26,760 --> 00:08:29,560 Now, in Microsoft, you can change that. 112 00:08:29,560 --> 00:08:33,520 You cannot change that in Linux. 113 00:08:33,660 --> 00:08:36,020 I wouldn't recommend trying to do that. 114 00:08:36,020 --> 00:08:40,180 You'd have to change a lot of underlying stuff to change that. 115 00:08:40,180 --> 00:08:43,060 And we'll look at the general format of the commands. 116 00:08:43,060 --> 00:08:48,200 It's not too difficult to work with, but there are just some things to be aware of. 117 00:08:48,200 --> 00:08:50,840 So, where did Linux come from? 118 00:08:50,840 --> 00:08:53,540 We outlined this in the slide right here. 119 00:08:53,540 --> 00:08:55,880 And so it began in 1969. 120 00:08:56,400 --> 00:09:00,780 AT&T, Bell Labs, they wanted to come up with a new operating system. 121 00:09:01,380 --> 00:09:05,380 In that same year, coincidentally, Linus Torvos was born. 122 00:09:05,480 --> 00:09:06,600 1969. 123 00:09:06,600 --> 00:09:18,300 So, in the late 1970s, AT&T decided to release Unix for universities and some commercial use. 124 00:09:18,300 --> 00:09:22,700 Before then, it was used only by AT&T. 125 00:09:22,740 --> 00:09:27,780 In 1987, not sure if you heard of this part. 126 00:09:27,780 --> 00:09:34,480 This gentleman named Andrew Tannenbaum wrote an operating system called Minix. 127 00:09:34,480 --> 00:09:40,440 And that kind of mimicked the operation of Unix. 128 00:09:40,440 --> 00:09:43,590 But he had that for educational purposes. 129 00:09:43,920 --> 00:09:52,500 In 1987, he came out with this book here, Operating Systems, that had some of the code in it. 130 00:09:52,500 --> 00:09:57,660 And this book was used by universities and places like that. 131 00:09:57,660 --> 00:10:03,680 I happened to see this book at least a few years later after that. 132 00:10:03,680 --> 00:10:08,500 I was hanging out in the Philippines for a while and I went in a bookstore. 133 00:10:08,580 --> 00:10:11,320 And they had a second printing of that. 134 00:10:11,320 --> 00:10:14,120 And it was a nice book and I purchased it. 135 00:10:14,120 --> 00:10:15,540 It's in my garage someplace. 136 00:10:15,540 --> 00:10:16,440 I looked for it. 137 00:10:16,440 --> 00:10:18,080 I can't find that book. 138 00:10:18,080 --> 00:10:20,000 But it's a nice book to have. 139 00:10:20,020 --> 00:10:27,080 So, in 1988, we have Linus Torvos who attends the University of Helsinki. 140 00:10:27,360 --> 00:10:30,640 He goes away for a little while and starts coming back. 141 00:10:30,640 --> 00:10:37,000 Anyway, Linus gets a copy of the book, the software, and he starts playing with it. 142 00:10:37,000 --> 00:10:39,200 He creates the Linux kernel. 143 00:10:40,000 --> 00:10:49,460 The other notable thing about the Linux kernel is that he changed the license of it to GNU Project. 144 00:10:49,460 --> 00:10:56,180 That way, you'd be able to sell it and whatnot and use it more for commercial use. 145 00:10:56,180 --> 00:11:00,820 That's basically how Linux came about from Unix. 146 00:11:00,820 --> 00:11:05,680 And we had that book about the operating systems. 147 00:11:06,160 --> 00:11:08,200 So, what is Linux? 148 00:11:08,200 --> 00:11:10,980 We're going to talk about what it is, what it's not. 149 00:11:10,980 --> 00:11:13,260 We know that it's an operating system. 150 00:11:13,260 --> 00:11:14,980 Linux has a kernel. 151 00:11:15,280 --> 00:11:21,540 And that kernel is the main thing that Linus Torvos works on. 152 00:11:21,620 --> 00:11:23,960 There are other pieces of it as well. 153 00:11:23,960 --> 00:11:25,970 The system bootloader. 154 00:11:26,490 --> 00:11:28,810 Several different types of bootloaders. 155 00:11:28,810 --> 00:11:30,670 And they're pretty good bootloaders. 156 00:11:31,010 --> 00:11:31,790 Grub. 157 00:11:31,790 --> 00:11:40,010 One nice thing about the Linux bootloaders is that they're good at loading in Microsoft Windows as well. 158 00:11:40,010 --> 00:11:41,350 So, dual boot. 159 00:11:41,350 --> 00:11:44,430 You would tend to put Linux on there first. 160 00:11:44,470 --> 00:11:47,390 So, you have the command line interpreter. 161 00:11:47,390 --> 00:11:49,150 Most of us know about Bash. 162 00:11:49,150 --> 00:11:52,490 You know, it could be any of these other ones we list. 163 00:11:52,490 --> 00:11:54,310 We have the SH shell. 164 00:11:54,310 --> 00:11:58,950 KSH shell, I believe, is for people who do systems development more. 165 00:11:58,950 --> 00:12:00,270 They would like that. 166 00:12:00,270 --> 00:12:02,170 There is the Bourne shell. 167 00:12:02,170 --> 00:12:03,950 Here is why I mentioned all of these. 168 00:12:03,950 --> 00:12:05,590 I mentioned the Bourne shell. 169 00:12:05,590 --> 00:12:07,610 What does Bash stand for? 170 00:12:07,630 --> 00:12:08,310 Bourne. 171 00:12:08,310 --> 00:12:09,270 Again. 172 00:12:09,270 --> 00:12:10,110 Shell. 173 00:12:10,110 --> 00:12:12,070 So, that's how we get Bash. 174 00:12:12,070 --> 00:12:16,810 You can have a graphics interface, you know, the GUI. 175 00:12:16,970 --> 00:12:19,160 And then you have package managers. 176 00:12:19,620 --> 00:12:23,020 It can be typically one of two types of package managers. 177 00:12:23,020 --> 00:12:25,120 You have the Red Hat one. 178 00:12:25,120 --> 00:12:28,020 We have the RPM, the YUM, all of that stuff. 179 00:12:28,020 --> 00:12:32,780 Or it can be typically out of the Debian affair where you have the APT. 180 00:12:32,780 --> 00:12:35,740 So, you tend to have one or the other. 181 00:12:36,000 --> 00:12:37,960 You have startup scripts. 182 00:12:37,960 --> 00:12:42,420 And I mentioned two here because it's going to be one of these two. 183 00:12:42,420 --> 00:12:46,840 You know, the system v, vinit, or the system d. 184 00:12:46,840 --> 00:12:51,320 The system d is, you know, the newer one that you tend to see on most systems. 185 00:12:52,160 --> 00:12:55,080 So, Linux, you have a file system. 186 00:12:55,080 --> 00:13:00,300 And I list ext3, which you probably won't see, ext4. 187 00:13:00,300 --> 00:13:05,880 And there are a number of other ones that btrfs is kind of new. 188 00:13:05,940 --> 00:13:16,820 Also, I decided to list FAT32, FAT64, because when you have things like these flash drives, you know, you're kind of using that. 189 00:13:16,840 --> 00:13:23,760 And Linux has other utilities and things that are involved with it. 190 00:13:26,580 --> 00:13:29,800 So, what the kernel is, what the kernel does. 191 00:13:29,800 --> 00:13:33,600 Basically, it is the central core of the machine. 192 00:13:33,600 --> 00:13:40,580 You know, it allocates the memory, does CPU scheduling, the IO, all of these things that we have here. 193 00:13:40,580 --> 00:13:50,300 And we list some of the kernel features, especially to allocate memory and to allocate the time of the CPU. 194 00:13:50,460 --> 00:13:53,440 Most of our computers now have multiple processes. 195 00:13:53,500 --> 00:13:56,860 So, the kernel schedules that. 196 00:13:56,860 --> 00:14:00,180 And you can see, you know, different processes being used. 197 00:14:00,180 --> 00:14:02,740 Okay, what is not in the kernel? 198 00:14:02,740 --> 00:14:04,340 And I believe this is important. 199 00:14:04,680 --> 00:14:08,360 The command line interpreter is not in the kernel. 200 00:14:08,360 --> 00:14:10,580 The GUI is not in the kernel. 201 00:14:10,640 --> 00:14:13,980 Commands, utility programs, those are not in the kernel. 202 00:14:13,980 --> 00:14:15,420 User programs. 203 00:14:15,840 --> 00:14:22,760 Now, sometimes hardware drivers, file systems, and these other things might not be in the kernel. 204 00:14:22,760 --> 00:14:26,140 They might or they might not be, depending upon what they are. 205 00:14:26,140 --> 00:14:29,100 Some of them can be loadable and unloadable. 206 00:14:29,100 --> 00:14:32,940 And so, those are not, you know, written into the kernel per se. 207 00:14:32,940 --> 00:14:35,000 But the kernel can connect to them. 208 00:14:35,000 --> 00:14:37,580 So, this is the current Linux kernel. 209 00:14:37,580 --> 00:14:41,040 It's out, you know, they update this, you know, pretty often. 210 00:14:44,500 --> 00:14:53,360 This version is out, I believe it was July 27, this latest version came out. 211 00:14:53,360 --> 00:14:56,720 So, where do we find the version of the kernel? 212 00:14:56,720 --> 00:14:59,480 And that's going to be in the slash boot directory. 213 00:14:59,480 --> 00:15:04,520 We're going to look more into the different directories and things in a little bit. 214 00:15:05,740 --> 00:15:10,580 If you're in Linux, you can see it by running the uname command. 215 00:15:10,580 --> 00:15:12,940 And there are different varieties of the command. 216 00:15:12,940 --> 00:15:17,220 You put one switch on it, the minus R, and then you get that little name. 217 00:15:17,220 --> 00:15:21,900 The big switch, minus A, you get all of, you know, where the kernel is. 218 00:15:22,200 --> 00:15:27,240 In terms of the source code of the kernel, we list where that is. 219 00:15:27,240 --> 00:15:29,640 You can go and take a look at it. 220 00:15:29,820 --> 00:15:35,720 Interesting thing about it, I believe it says it's 98 point something percent C code. 221 00:15:35,720 --> 00:15:39,760 And on GitHub, it lists what the other variants of it are. 222 00:15:39,760 --> 00:15:44,880 And by the way, it is very good, very well written C code. 223 00:15:44,880 --> 00:15:46,880 Every time I look at it, I'm envious. 224 00:15:46,880 --> 00:15:50,100 I'm like, I've never seen C look this good. 225 00:15:50,100 --> 00:15:53,460 But yeah, they do a very good job at writing that. 226 00:15:53,520 --> 00:16:00,240 Okay, so here's a little illustration that we have that talks about some of the things that are in the kernel. 227 00:16:00,240 --> 00:16:04,380 And we call this the syscall because, you know, system calls. 228 00:16:04,380 --> 00:16:07,940 So, we see this directory path. 229 00:16:07,940 --> 00:16:11,640 Don't worry, you know, you have copy of the slides. 230 00:16:11,760 --> 00:16:18,200 But this directory path has some of the different files of the system calls. 231 00:16:18,200 --> 00:16:20,240 And I highlight where they are. 232 00:16:20,580 --> 00:16:27,920 It's a little tricky finding these because there is also a file called syscall.h, a header file. 233 00:16:27,920 --> 00:16:30,720 But the files are not really listed in there. 234 00:16:30,720 --> 00:16:37,180 And so, I guess when you're compiling, the kernel is winding through all of this stuff to find it. 235 00:16:37,840 --> 00:16:43,700 So, the unistd, we have it for 64-bit and 32-bit. 236 00:16:43,700 --> 00:16:49,560 These are where we can find the different syscalls of the kernel. 237 00:16:50,020 --> 00:16:55,420 So, take a look at a few of these in unist32. 238 00:16:55,580 --> 00:16:57,820 I highlight two of them. 239 00:16:57,820 --> 00:17:01,600 One is the exit, and that's going to be syscall number one. 240 00:17:01,600 --> 00:17:04,820 I highlight the right, syscall number four. 241 00:17:04,820 --> 00:17:06,840 You see a few other ones too. 242 00:17:06,840 --> 00:17:08,960 You see the open and the close. 243 00:17:08,960 --> 00:17:12,300 You see the read in addition to the write. 244 00:17:12,300 --> 00:17:14,940 You're wondering, why is DJ mentioning this? 245 00:17:14,940 --> 00:17:16,540 Okay, let's go to the next slide. 246 00:17:16,540 --> 00:17:30,140 Okay, so, strace is a nice utility that prints out where a program does its system calls. 247 00:17:30,140 --> 00:17:36,180 And basically, we run this by saying the program is an assembly language program. 248 00:17:37,440 --> 00:17:38,320 HelloASM. 249 00:17:38,320 --> 00:17:41,300 And all it does is basically print hello world. 250 00:17:41,320 --> 00:17:42,920 Most of us are familiar with that. 251 00:17:42,920 --> 00:17:49,820 The first thing that you generally do in a language is find out how you print something, hello world, and you do that. 252 00:17:49,860 --> 00:17:53,640 And so, this is the strace of hello world. 253 00:17:53,640 --> 00:17:55,820 There is not a whole lot there. 254 00:17:55,880 --> 00:17:59,960 And it basically does three system calls. 255 00:17:59,960 --> 00:18:02,920 The first one to get in there and start running. 256 00:18:03,180 --> 00:18:05,700 The next one, we're going to do a write. 257 00:18:05,700 --> 00:18:09,900 And it tells the OS how much it's going to write. 258 00:18:09,900 --> 00:18:11,620 And we do an exit. 259 00:18:11,620 --> 00:18:17,360 So, I bolded the system calls in red. 260 00:18:17,360 --> 00:18:26,000 When you see the assembly program over there, you see how we're moving things into a few registers. 261 00:18:26,000 --> 00:18:27,560 And we call the routine. 262 00:18:27,560 --> 00:18:33,220 And so, that directly reflects what we see in the strace. 263 00:18:33,220 --> 00:18:36,580 So, that's for a little assembly language program. 264 00:18:36,660 --> 00:18:41,200 Let's take a look at the one for the C program. 265 00:18:41,260 --> 00:18:44,040 And again, don't worry, not an eye exam. 266 00:18:44,040 --> 00:18:46,400 You have the slides from this. 267 00:18:46,920 --> 00:18:49,600 So, we see a couple of things in here. 268 00:18:49,600 --> 00:18:53,640 We see that there are a whole bunch of system calls. 269 00:18:53,780 --> 00:19:00,340 One of the reasons why C, like other languages, has a standard library. 270 00:19:00,340 --> 00:19:03,120 That standard library does a lot of stuff. 271 00:19:03,120 --> 00:19:08,700 Now, don't worry about all the stuff that it does, because this program actually runs quite quickly. 272 00:19:08,700 --> 00:19:10,800 You know, a couple of milliseconds. 273 00:19:11,040 --> 00:19:14,880 But it does all of these system calls to get things done. 274 00:19:14,960 --> 00:19:22,580 One thing that I will say about the standard library that is unique is that it does buffered I-O. 275 00:19:22,580 --> 00:19:24,540 Buffered I-O is very good. 276 00:19:24,540 --> 00:19:25,420 Here's why. 277 00:19:25,420 --> 00:19:28,980 I'll see if I can cursor up to this assembly program for a second. 278 00:19:29,240 --> 00:19:33,880 You see, if we're writing this in assembly, we're not going to be doing this often. 279 00:19:33,880 --> 00:19:39,980 But if we were doing this, we would do a little something, and then we would do a system call. 280 00:19:39,980 --> 00:19:44,000 We might build something else, print it with a system call. 281 00:19:44,060 --> 00:19:55,620 System calls are relatively expensive, because the computer has to do things, and saving the state of where it is, transferring control to the operating system, and all of that. 282 00:19:55,620 --> 00:19:59,760 Now, I mean, it does this, you know, hundreds of thousands of times a second. 283 00:19:59,760 --> 00:20:02,300 But still, it's a relatively slow process. 284 00:20:02,360 --> 00:20:12,960 But C, the C library does buffering, so it takes all of this stuff, and puts it in memory, and writes it out in one operation. 285 00:20:12,960 --> 00:20:15,560 So, it's a lot more efficient to do that. 286 00:20:15,560 --> 00:20:17,720 So, you know, that standard library is good. 287 00:20:17,720 --> 00:20:24,580 But still, we see how it's doing things like opening files, and things like that. 288 00:20:24,580 --> 00:20:32,620 Um, we mentioned standard in, standard out, and a standard error. 289 00:20:32,920 --> 00:20:37,260 I think we said those files are automatically open for you. 290 00:20:37,260 --> 00:20:43,180 And when we take a look at this, we actually see these numbers in here. 291 00:20:43,320 --> 00:20:52,880 When the standard library goes to open a file, it picks file number three. 292 00:20:52,880 --> 00:20:54,850 Why file number three? 293 00:20:55,380 --> 00:21:04,210 Because zero is always standard in, um, one is always standard out, and two is always standard error. 294 00:21:04,860 --> 00:21:09,280 C knows that, and so it knows where to start picking its files. 295 00:21:09,300 --> 00:21:09,890 Anyway. 296 00:21:11,020 --> 00:21:13,360 So, how to log in. 297 00:21:13,360 --> 00:21:17,740 We're not really going to talk about logging into Linux. 298 00:21:17,740 --> 00:21:19,920 But let's talk about the run levels. 299 00:21:19,920 --> 00:21:24,900 Because the run levels are important for how we do log in. 300 00:21:24,900 --> 00:21:30,700 Whether or not it is, you know, a CLI, you know, a tech screen. 301 00:21:30,700 --> 00:21:32,560 Or whether it's the GUI. 302 00:21:32,560 --> 00:21:34,760 And so there are different run levels. 303 00:21:34,760 --> 00:21:43,480 All the way from shutting down the computer to single user, multi-user, GUI. 304 00:21:43,480 --> 00:21:45,520 And we see run level six. 305 00:21:45,520 --> 00:21:48,860 You can tell the computer, run level six. 306 00:21:48,860 --> 00:21:53,820 And if you have like, um, root privileges, you know what it's going to do? 307 00:21:53,960 --> 00:21:54,740 Reboot. 308 00:21:54,740 --> 00:21:56,600 Because that's what run level six is. 309 00:21:56,600 --> 00:21:58,160 It loads in those scripts. 310 00:21:58,380 --> 00:22:01,700 I say a little something about Ubuntu in here. 311 00:22:01,880 --> 00:22:07,780 Because they do several of the run levels, you know, it's going to be like five. 312 00:22:07,780 --> 00:22:09,520 No matter which one you pick. 313 00:22:09,520 --> 00:22:16,920 Several of them, Debian, Ubuntu, is going to be like, you know, going into, um, into the GUI. 314 00:22:18,220 --> 00:22:20,840 So, what's available in the GUI? 315 00:22:20,920 --> 00:22:22,980 Here is a list of, you know, the different programs. 316 00:22:22,980 --> 00:22:30,180 A lot of the stuff that we would see on a Windows system is there. 317 00:22:30,680 --> 00:22:33,940 Different names of the program, because different people write that. 318 00:22:33,940 --> 00:22:35,280 But they're all free. 319 00:22:38,490 --> 00:22:41,250 Using the terminal, when you go into the CLI. 320 00:22:41,250 --> 00:22:43,970 These are just some of the commands that you would try. 321 00:22:43,970 --> 00:22:47,010 And I'll mention a little something about each one of these. 322 00:22:47,010 --> 00:22:50,270 So, the date command, you know, it's going to tell you the date. 323 00:22:50,370 --> 00:22:53,850 In Windows, you have the date command to give you the date. 324 00:22:53,850 --> 00:22:56,710 The time command to give you the time of day. 325 00:22:56,850 --> 00:23:00,510 That's not exactly the same way it is in Linux. 326 00:23:00,510 --> 00:23:04,390 The date command will give you the time and date. 327 00:23:04,490 --> 00:23:09,750 Because the time command will actually time how long it takes a program to run. 328 00:23:09,750 --> 00:23:12,190 How much time it spends in system space. 329 00:23:12,190 --> 00:23:14,570 How much time it spends in user space. 330 00:23:14,570 --> 00:23:18,910 If you type in time on a Linux system, don't worry. 331 00:23:18,910 --> 00:23:23,810 It's just going to come back and say you didn't put in a program or whatnot. 332 00:23:24,110 --> 00:23:28,030 Uptime tells you how long the computer has been running. 333 00:23:28,030 --> 00:23:33,730 It's a lot easier to find that in Linux than it is to find it in Windows. 334 00:23:33,730 --> 00:23:41,370 Sometimes you have to look on a Windows system and try different things to figure out how long has the server been up. 335 00:23:42,070 --> 00:23:44,030 There are other commands. 336 00:23:44,030 --> 00:23:45,710 Say we have the who command. 337 00:23:45,710 --> 00:23:47,430 You put different options on it. 338 00:23:47,430 --> 00:23:53,390 And by the way, the options, we call those, we might say minus A. 339 00:23:53,690 --> 00:23:56,190 We might want to say like dash A. 340 00:23:56,190 --> 00:24:00,430 But Linux people, they generally say minus or whatnot. 341 00:24:00,430 --> 00:24:01,510 That's okay. 342 00:24:02,390 --> 00:24:06,290 Using the terminal, you can string commands together. 343 00:24:06,290 --> 00:24:07,590 Put in that semicolon. 344 00:24:07,590 --> 00:24:09,290 That's a separator. 345 00:24:09,290 --> 00:24:11,390 Ps for processes. 346 00:24:11,390 --> 00:24:15,610 It's funny how people in Unix just abbreviated stuff. 347 00:24:15,610 --> 00:24:17,190 It's like they don't like to type. 348 00:24:17,190 --> 00:24:21,030 You know, they tend to type very fast, but they have shorthand commands. 349 00:24:21,030 --> 00:24:23,610 And it's all typically in lowercase. 350 00:24:23,610 --> 00:24:27,710 Case matters totally in Linux. 351 00:24:27,830 --> 00:24:29,990 I know, the case can be annoying. 352 00:24:30,110 --> 00:24:32,230 But yeah, it matters. 353 00:24:32,230 --> 00:24:35,570 And so you make sure that you get that exactly correct. 354 00:24:38,110 --> 00:24:40,830 Other things for using the terminal. 355 00:24:41,470 --> 00:24:46,210 Windows, well, Linux has its own help system. 356 00:24:46,210 --> 00:24:48,370 And we call those the man pages. 357 00:24:48,690 --> 00:24:50,550 Man is short for what? 358 00:24:50,650 --> 00:24:51,430 Manual. 359 00:24:51,910 --> 00:24:56,810 So the man pages, just about every command has an entry in it. 360 00:24:56,810 --> 00:24:58,870 You might find a few things that don't. 361 00:24:58,870 --> 00:24:59,690 It's kind of funny. 362 00:24:59,690 --> 00:25:01,370 At that point, you just go Google. 363 00:25:01,370 --> 00:25:05,610 Whoever designed the package, for whatever reason, didn't create a man page. 364 00:25:05,610 --> 00:25:07,210 DF disk free. 365 00:25:07,210 --> 00:25:09,010 And you can give it different options. 366 00:25:09,010 --> 00:25:16,310 I like the minus H option on DF because it gives you what stands for human readable. 367 00:25:16,370 --> 00:25:21,910 So it'll give you the file sizes and KB, MB, and those types of things. 368 00:25:21,910 --> 00:25:27,290 Just whatever is usable at that point for the size of it. 369 00:25:27,290 --> 00:25:28,050 Okay. 370 00:25:29,690 --> 00:25:33,650 So this is how the file system is laid out. 371 00:25:33,650 --> 00:25:35,310 We mentioned forward slash. 372 00:25:35,310 --> 00:25:36,590 And that's root. 373 00:25:36,730 --> 00:25:39,570 A few directories hang off of root. 374 00:25:39,570 --> 00:25:40,770 And we list them here. 375 00:25:40,770 --> 00:25:42,130 For example, the boot. 376 00:25:42,130 --> 00:25:48,230 Remember we were saying when you boot up the system, the kernel and stuff that's in the slash boot directory. 377 00:25:48,490 --> 00:25:54,130 Then we have slash Etsy, or we might call it etc, etc. 378 00:25:54,570 --> 00:25:56,250 Often we call it Etsy. 379 00:25:56,250 --> 00:25:59,090 And you have a number of system configuration files. 380 00:25:59,090 --> 00:26:01,850 Not all of them, but a lot of them there. 381 00:26:02,410 --> 00:26:05,910 Slash home is where you put the home directories. 382 00:26:05,910 --> 00:26:07,970 Generally one for each user. 383 00:26:09,230 --> 00:26:10,650 Slash root. 384 00:26:10,650 --> 00:26:16,570 The root user has his own separate directory, separate from home. 385 00:26:16,570 --> 00:26:18,910 Now why would we want to do that? 386 00:26:18,910 --> 00:26:24,950 Maybe the users might fill up the partition that has the home directories. 387 00:26:24,950 --> 00:26:28,790 Well, you want the root user to still be able to do their thing. 388 00:26:28,790 --> 00:26:30,870 So they're going to be in a different space. 389 00:26:30,870 --> 00:26:33,330 They can be in a different space in the file system. 390 00:26:33,830 --> 00:26:36,710 So we see a number of the different ones that we have. 391 00:26:36,710 --> 00:26:40,970 We have usr, we call it user, user bin. 392 00:26:41,010 --> 00:26:45,030 But we see that user, some people say, well that's where you put user files. 393 00:26:45,030 --> 00:26:47,710 No, that's not exactly what it means. 394 00:26:47,710 --> 00:26:53,570 It comes from a specific term from the Unix system. 395 00:26:53,770 --> 00:26:58,870 But in any event, that is where you have the non-changeable files. 396 00:26:58,870 --> 00:27:02,950 Your programs and things like that will sit someplace. 397 00:27:02,950 --> 00:27:05,130 User bin, bin for binary. 398 00:27:05,550 --> 00:27:08,870 User sbin for super user binary. 399 00:27:08,870 --> 00:27:14,090 You know, programs that perhaps only the root user might use will be sitting there. 400 00:27:14,090 --> 00:27:18,210 You have user lib for your programs and things like that. 401 00:27:18,210 --> 00:27:20,130 And you can have links to these. 402 00:27:20,130 --> 00:27:25,930 For example, bin is actually a symbolic link pointing to user bin. 403 00:27:25,930 --> 00:27:31,210 So that kind of helps to make the system more flexible. 404 00:27:31,450 --> 00:27:36,690 So we have var, which is like variable length files and things. 405 00:27:36,690 --> 00:27:39,590 Your logs and things might go into var. 406 00:27:40,650 --> 00:27:48,910 That forward slash proc is a very interesting directory because it's not actually a file system on disk. 407 00:27:48,910 --> 00:27:50,750 It is something that's simulated. 408 00:27:50,750 --> 00:28:00,470 And what it is, is it takes memory parameters and it puts it like it's a disk file so you can read them and write them. 409 00:28:00,470 --> 00:28:06,830 But those are lots of parameters dealing with the memory and the processes that are running on the computer. 410 00:28:06,830 --> 00:28:10,810 The last one we list here is the sys one. 411 00:28:11,490 --> 00:28:16,410 And that has parameters generally that you can read and set. 412 00:28:16,410 --> 00:28:19,650 And you would change the operation of the kernel. 413 00:28:19,650 --> 00:28:25,830 You can update the parameters of the machine while it's still running. 414 00:28:27,750 --> 00:28:30,850 Here we look at moving around the file system. 415 00:28:30,850 --> 00:28:38,250 And these are just commands to know pwd, print working directory, still like on Microsoft. 416 00:28:38,630 --> 00:28:40,850 They can work a little bit different. 417 00:28:41,410 --> 00:28:46,770 You can list files, ls stands for list, cd for change directory. 418 00:28:46,770 --> 00:28:50,690 If it's a hidden file, we're going to have a dot in front of it. 419 00:28:50,690 --> 00:28:54,210 So a dot in front of a file name means that it's hidden. 420 00:28:54,210 --> 00:28:55,530 How do we see that? 421 00:28:55,530 --> 00:29:01,730 Use the list command ls minus a, you will see those files as well. 422 00:29:01,730 --> 00:29:04,790 I mentioned the dot and the dot dot. 423 00:29:04,790 --> 00:29:07,490 Now Microsoft does this as well. 424 00:29:07,510 --> 00:29:10,990 And the dot is helpful for when you're moving around. 425 00:29:10,990 --> 00:29:14,610 That just means the directory where I am. 426 00:29:14,610 --> 00:29:17,610 Dot dot is the parent directory. 427 00:29:17,690 --> 00:29:22,850 Say for example, you're someplace, you're in home, you know, my directory. 428 00:29:22,850 --> 00:29:24,630 And you want to move up to the home. 429 00:29:24,630 --> 00:29:28,770 You just say change directory cd dot dot and it moves up. 430 00:29:28,770 --> 00:29:35,010 And that is the same as for Microsoft in a lot of cases. 431 00:29:36,630 --> 00:29:39,370 So there are some other things that we use. 432 00:29:39,370 --> 00:29:42,670 And you will see a little bit about this in a little while. 433 00:29:42,670 --> 00:29:46,670 For example, changing the permissions of the file. 434 00:29:47,510 --> 00:29:50,410 They call it change mode in Linux. 435 00:29:50,450 --> 00:29:52,350 Well, you know, that's an interesting one. 436 00:29:52,350 --> 00:29:55,730 Change owner, you can change who owns the file. 437 00:29:55,730 --> 00:30:01,330 The stat command is nice because it gives you a lot of attributes on the file. 438 00:30:01,330 --> 00:30:08,350 You know, the dates, the date when it was created, the date that it was updated, and lots of those. 439 00:30:08,350 --> 00:30:12,990 And other things about, you know, the file pointers and things. 440 00:30:12,990 --> 00:30:17,040 Okay, let's talk a moment about the file permissions. 441 00:30:17,570 --> 00:30:20,770 This is not necessarily difficult. 442 00:30:20,770 --> 00:30:28,590 And I believe that it can be easier than it is for Windows. 443 00:30:28,870 --> 00:30:31,870 So we see a directory. 444 00:30:31,870 --> 00:30:34,830 And in this case, we have some notable people. 445 00:30:34,830 --> 00:30:39,350 There are some very good inventors who have given us a lot of good stuff. 446 00:30:39,350 --> 00:30:44,250 But we see the RW, and that's for read, write. 447 00:30:44,250 --> 00:30:47,010 The third position, we call it execute. 448 00:30:47,050 --> 00:30:48,150 And that repeats. 449 00:30:48,150 --> 00:30:49,490 Read, write, execute. 450 00:30:49,490 --> 00:30:50,770 Read, write, execute. 451 00:30:50,770 --> 00:30:52,690 Why do we have that three times? 452 00:30:52,690 --> 00:30:59,470 The middle of the slide kind of tells us that it's going to be for that user who owns that file. 453 00:30:59,470 --> 00:31:04,510 The group that the file belongs to is always going to belong to a group. 454 00:31:04,510 --> 00:31:08,390 Even if it's the name of the owner, it's going to have a group. 455 00:31:08,450 --> 00:31:09,410 And other. 456 00:31:09,410 --> 00:31:12,890 Other is everybody else in the world who's using the system. 457 00:31:12,890 --> 00:31:16,130 So you can have privileges for that or not. 458 00:31:16,230 --> 00:31:20,710 Below that, I give you a little matrix of how that works out. 459 00:31:20,710 --> 00:31:22,390 We come up with a number. 460 00:31:22,390 --> 00:31:25,710 So if it is a read, we have number four. 461 00:31:25,710 --> 00:31:28,210 If it is a write, number two. 462 00:31:28,210 --> 00:31:31,670 And if it's execute, it's one. 463 00:31:31,670 --> 00:31:36,670 So if they have read, write, execute, it's going to be four plus two plus one. 464 00:31:36,990 --> 00:31:45,030 Now you can change the permissions of the file by using three numbers. 465 00:31:45,030 --> 00:31:46,910 And that will represent all of those. 466 00:31:46,910 --> 00:31:50,530 Whether it'll be anywhere from a zero to a seven for the user. 467 00:31:50,650 --> 00:31:52,950 A zero to seven for the group. 468 00:31:52,950 --> 00:31:55,390 And a zero to seven for the owner. 469 00:31:55,450 --> 00:31:56,970 You can change all of that. 470 00:31:56,970 --> 00:31:59,350 There are other ways that you can do it as well. 471 00:31:59,350 --> 00:32:00,890 And I didn't list those. 472 00:32:00,890 --> 00:32:06,350 It's like you can change a U, a plus this, a plus G, a minus that. 473 00:32:06,450 --> 00:32:11,730 I think it's a lot easier just knowing the numbers and doing that. 474 00:32:11,730 --> 00:32:14,130 So this is something that you'll play with. 475 00:32:14,290 --> 00:32:17,190 Get on there and look at the files and things. 476 00:32:17,430 --> 00:32:22,850 And if you haven't done it, I think you'll find it's not that difficult to do. 477 00:32:22,970 --> 00:32:25,010 Now, so what are the effects of this? 478 00:32:25,010 --> 00:32:33,210 On this slide, we tell you what is affected for changing in a file if you change the read. 479 00:32:33,210 --> 00:32:36,690 And that's pretty obvious, I think. 480 00:32:37,230 --> 00:32:40,970 If they have that permission, that person can read the file. 481 00:32:40,970 --> 00:32:43,510 They don't have it, they can't read the file. 482 00:32:43,730 --> 00:32:45,190 And the same thing for write. 483 00:32:45,190 --> 00:32:53,010 And that execute means if it is a program or a script, whether or not they can run it. 484 00:32:53,010 --> 00:32:56,890 If it's not a script or program, forget about the execute. 485 00:32:57,490 --> 00:33:00,530 So directories have these permissions too. 486 00:33:00,750 --> 00:33:06,990 And they have slightly similar nuanced meanings for directory. 487 00:33:06,990 --> 00:33:08,830 But we list this here as well. 488 00:33:09,170 --> 00:33:13,630 You know, whether you can read a file that's in the directory. 489 00:33:13,770 --> 00:33:17,950 Write is whether you can write to it or delete the file. 490 00:33:17,950 --> 00:33:21,950 Because in any event, you're writing to something in order to delete. 491 00:33:21,950 --> 00:33:25,350 And execute means, can I even get in there? 492 00:33:25,610 --> 00:33:34,470 So by changing these, you can set up a lot of who can get in and see what and do what and what have you. 493 00:33:34,470 --> 00:33:39,710 Now that root user, super user, can get to all sorts of stuff. 494 00:33:44,090 --> 00:33:47,250 So we talked about that proc directory. 495 00:33:47,790 --> 00:33:50,450 Proc is interesting, proc is fun. 496 00:33:50,450 --> 00:33:59,550 First thing about proc, and I did not list here, but for every process that's running, it's going to have a PID, a process ID, a number. 497 00:33:59,770 --> 00:34:03,850 And there is going to be a number there for that process. 498 00:34:03,850 --> 00:34:11,550 If you were to go into that directory of that number, you can see lots of parameters about that process. 499 00:34:11,610 --> 00:34:19,490 Now there are some other things, a lot of things as we list here, that are simply files that you can list in. 500 00:34:19,490 --> 00:34:22,990 And see some things that are going on. 501 00:34:22,990 --> 00:34:24,290 So what are some of these things? 502 00:34:24,290 --> 00:34:25,870 I'll list a few of them. 503 00:34:25,970 --> 00:34:31,250 Now my favorite one is the second one, CPU info. 504 00:34:31,330 --> 00:34:36,230 And that is where you can get detailed information on all of the CPUs. 505 00:34:37,970 --> 00:34:44,050 You can see the strings of the CPU that tells all of their options. 506 00:34:44,390 --> 00:34:48,130 Typically everything is now 64-bit, but it wasn't. 507 00:34:48,130 --> 00:34:57,990 There are some flags in there that will indicate that it's 64-bit, about the type of co-processes and things that it has. 508 00:34:58,030 --> 00:35:06,030 Another thing that is interesting about the CPU info, when you take a look at it, it's going to be kind of odd. 509 00:35:06,310 --> 00:35:11,190 You're going to see multiple CPUs, because every computer nowadays has multiple CPUs. 510 00:35:11,190 --> 00:35:16,050 You're going to see the frequency of the CPU, how fast that thing is running. 511 00:35:16,050 --> 00:35:18,570 Let's say you have eight CPUs. 512 00:35:18,570 --> 00:35:21,090 Here is what you're not going to see. 513 00:35:21,130 --> 00:35:26,230 You're not going to see all of them listing the same exact frequency. 514 00:35:26,230 --> 00:35:29,970 The frequencies of the microprocessors vary a bit. 515 00:35:29,970 --> 00:35:31,810 And they're going to have different numbers. 516 00:35:31,810 --> 00:35:35,670 But in a way, you'll see all of this on CPU info. 517 00:35:35,670 --> 00:35:44,470 When you run commands and things that show you what the CPU is doing, it's pulling it from this file that's in this directory. 518 00:35:45,030 --> 00:35:46,930 The same thing for the other ones. 519 00:35:47,210 --> 00:35:48,250 Meminfo. 520 00:35:48,950 --> 00:35:55,430 All of that gets written to that file as if it is a file on the operating system. 521 00:35:55,430 --> 00:35:56,070 But it's not. 522 00:35:56,070 --> 00:36:02,510 It's a pretty instantaneous spot where you can read and write and whatnot and get all the different versions. 523 00:36:03,210 --> 00:36:12,890 One thing that we're going to say about Linux, and we'll say it a couple of times, is that on a Linux system, everything is a file. 524 00:36:12,890 --> 00:36:15,430 But we'll get to that a little bit more in a moment. 525 00:36:15,430 --> 00:36:16,170 OK. 526 00:36:16,170 --> 00:36:18,150 So command line editing. 527 00:36:18,150 --> 00:36:20,490 Here's the stuff that you'll be using. 528 00:36:20,750 --> 00:36:23,130 You're probably used to a lot of this. 529 00:36:23,230 --> 00:36:25,390 Ctrl-C to end a program. 530 00:36:25,410 --> 00:36:29,470 You can up arrow, down arrow, go back into previous commands. 531 00:36:31,010 --> 00:36:33,350 You know, I forget if Microsoft does this. 532 00:36:33,350 --> 00:36:35,070 Ctrl-S and Ctrl-Q. 533 00:36:35,070 --> 00:36:37,210 Let's say you have a listing that's scrolling. 534 00:36:37,210 --> 00:36:38,950 You know, Ctrl-Q, Ctrl-S. 535 00:36:38,950 --> 00:36:41,110 You know, make it stop, go, stop, go. 536 00:36:41,750 --> 00:36:45,110 We used to do that on terminals, you know, way back in the day. 537 00:36:45,590 --> 00:36:54,390 Ctrl-D is interesting because if you're typing input into a program, say you're building a file from the command line. 538 00:36:54,390 --> 00:36:56,830 I want to put, you know, maybe three or four lines in this. 539 00:36:56,830 --> 00:36:58,890 How do you tell it that you're done with the input? 540 00:36:58,890 --> 00:37:00,090 Ctrl-D. 541 00:37:00,230 --> 00:37:06,290 Ctrl-Z will suspend the file, a file, a program that's running. 542 00:37:06,290 --> 00:37:08,790 And you can go back and resume the program. 543 00:37:08,790 --> 00:37:13,670 You can take programs and you can put it in the foreground, the foreground, and the background. 544 00:37:15,830 --> 00:37:26,790 Something that I list in here that's a little interesting, just to know, in working on Linux, we're used to Ctrl-C, Ctrl-V, you know, copy, paste. 545 00:37:26,970 --> 00:37:33,270 When you're in the CLI, a lot of times you have to do Shift-Ctrl-C, Shift-Ctrl-V. 546 00:37:33,270 --> 00:37:35,770 That's just a little something you get used to. 547 00:37:35,770 --> 00:37:36,330 OK. 548 00:37:36,330 --> 00:37:42,010 So, we mentioned the three files that are associated with every running process. 549 00:37:42,010 --> 00:37:44,510 The standard in, standard out, standard error. 550 00:37:44,510 --> 00:37:48,850 And we see that there are 0, 1, and 2, the file numbers. 551 00:37:48,850 --> 00:37:50,630 They're always going to be that. 552 00:37:50,630 --> 00:38:01,750 So, the input by default is going to be, from the keyboard, the output by default, the user screen, standard error by default, the user screen. 553 00:38:02,430 --> 00:38:07,810 Remember we said in Linux, everything is considered to be a file. 554 00:38:08,230 --> 00:38:14,890 Now, that standard input and output can be redirected to other places. 555 00:38:14,890 --> 00:38:19,310 You can send standard output to a file. 556 00:38:19,310 --> 00:38:22,230 In other words, you get the output just right at the disk somewhere. 557 00:38:22,230 --> 00:38:25,250 Or you can send it into another program. 558 00:38:25,250 --> 00:38:27,330 You can pipe it into another program. 559 00:38:27,330 --> 00:38:30,950 And that becomes its standard in to another program. 560 00:38:31,750 --> 00:38:32,590 OK. 561 00:38:33,230 --> 00:38:36,050 So, everything is a file in Linux. 562 00:38:36,050 --> 00:38:37,550 So, what about Windows? 563 00:38:37,550 --> 00:38:40,650 Windows does not treat this the same. 564 00:38:40,650 --> 00:38:45,670 Windows tends to have APIs, application programming interfaces. 565 00:38:45,670 --> 00:38:47,770 And I mentioned PowerShell applets. 566 00:38:47,770 --> 00:38:55,330 When you use PowerShell, and PowerShell is good to use because, you know, in addition to Windows, I mean, Linux will be working with Windows. 567 00:38:55,330 --> 00:38:58,770 You will see that, as I joke, there are billions of them. 568 00:38:58,770 --> 00:39:05,650 But that is, you know, just a fundamentally different way of doing things between the two operating systems. 569 00:39:10,070 --> 00:39:18,930 So, I mentioned that, well, I listed here that many operations and things can be done by open reading and closing a file. 570 00:39:18,930 --> 00:39:24,930 And I was mentioning the PROC FILE SYSTEM is a good example for doing all of that. 571 00:39:30,090 --> 00:39:35,410 A little bit more on using the terminal because we talked about redirecting stuff. 572 00:39:35,410 --> 00:39:39,670 You know, you see that greater than redirecting, you know, output. 573 00:39:39,670 --> 00:39:43,470 You know, you can say, okay, send it into my output into a file. 574 00:39:43,470 --> 00:39:44,930 You know, I'm listing a directory. 575 00:39:44,930 --> 00:39:46,110 Send it to a file. 576 00:39:46,110 --> 00:39:48,050 You know, I want to keep that output. 577 00:39:49,150 --> 00:39:51,410 You will see the double arrow. 578 00:39:51,410 --> 00:39:55,750 And the difference between that is the single arrow will write the file. 579 00:39:55,750 --> 00:40:01,430 If something is there, it will overlay it, erase it, and, you know, start writing anew. 580 00:40:01,430 --> 00:40:04,310 The double arrow, it will append to the file. 581 00:40:04,310 --> 00:40:06,530 That's the only difference between the two. 582 00:40:06,530 --> 00:40:10,990 The less than sign is you can redirect the input. 583 00:40:12,230 --> 00:40:16,490 So, on this slide, we list a few examples of that. 584 00:40:16,490 --> 00:40:19,290 So , we see we have the PIPE command. 585 00:40:19,290 --> 00:40:23,090 And we have the ampersand, which is used to put something in the background. 586 00:40:23,090 --> 00:40:26,650 And this is where it's good to look at these examples right here. 587 00:40:26,790 --> 00:40:31,030 Because the first one, we see that we run a listing. 588 00:40:31,030 --> 00:40:36,150 And we redirect that to a file. 589 00:40:36,330 --> 00:40:41,230 In terms of redirecting the input, the sort is a very good command. 590 00:40:41,230 --> 00:40:48,990 Because by default, the sort command will look to the standard input for something. 591 00:40:49,150 --> 00:40:51,950 Typically, we're not going to be typing in that. 592 00:40:51,950 --> 00:40:52,950 You know, we can. 593 00:40:52,950 --> 00:40:54,250 But typically, we're not. 594 00:40:54,250 --> 00:40:55,470 It's going to be a file. 595 00:40:55,470 --> 00:40:58,410 So, we redirect the input to a file. 596 00:40:58,410 --> 00:41:00,950 And we can redirect the output. 597 00:41:01,110 --> 00:41:04,470 Because if we don't, sort is just going to list it on the screen. 598 00:41:05,090 --> 00:41:08,690 But, you know, that's a very good example of doing that. 599 00:41:08,890 --> 00:41:12,170 I apologize for the next one where the find is an uppercase. 600 00:41:12,170 --> 00:41:14,750 That uppercase F is not going to work. 601 00:41:14,750 --> 00:41:16,770 That's what happens when you use PowerPoint. 602 00:41:16,770 --> 00:41:18,970 It wants to change each one of those. 603 00:41:18,970 --> 00:41:24,670 But we give an example of the two-in-one operator. 604 00:41:24,670 --> 00:41:32,490 The thing about the two-in-one is that I mentioned standard out, which is file handle one. 605 00:41:32,490 --> 00:41:36,070 And standard error, which is file handle two. 606 00:41:36,070 --> 00:41:37,910 And those are two different things. 607 00:41:37,910 --> 00:41:45,070 And even if they're both going to the screen, they can be separate things. 608 00:41:45,070 --> 00:41:50,370 Or a program might, by default, send those someplace else. 609 00:41:50,370 --> 00:41:55,370 But even if it does, we can combine those into one listing. 610 00:41:55,370 --> 00:41:57,090 A lot of times we don't want to. 611 00:41:57,090 --> 00:41:59,710 But if we need to, we can do that. 612 00:41:59,750 --> 00:42:03,350 So we see a few examples of using that pipe command. 613 00:42:03,350 --> 00:42:05,650 And we use pipe on Windows as well. 614 00:42:05,650 --> 00:42:13,130 But, you know, you can take output and redirect it to another program and do things. 615 00:42:13,810 --> 00:42:17,990 What we're doing in the two examples here is counting something. 616 00:42:17,990 --> 00:42:22,430 When we say who, it's going to give you a list of the people who are logged into the system. 617 00:42:22,850 --> 00:42:24,890 In this case, we want to know how many. 618 00:42:24,890 --> 00:42:28,890 So we pipe that into WC, which is word count. 619 00:42:28,910 --> 00:42:30,370 And we say minus L. 620 00:42:30,370 --> 00:42:34,310 Give us the lines, not the characters, you know, not all of that. 621 00:42:34,310 --> 00:42:36,850 Because word count will give you different numbers. 622 00:42:37,330 --> 00:42:40,350 So minus L will give you just the lines. 623 00:42:40,470 --> 00:42:43,450 The same thing if I want to know how many files are on a disk. 624 00:42:43,450 --> 00:42:44,350 Oh, I'm not on a disk. 625 00:42:44,350 --> 00:42:46,710 In a directory, we will list it. 626 00:42:47,510 --> 00:42:52,050 Use the minus L so we get one thing for each file. 627 00:42:52,050 --> 00:42:54,190 And send that to word count. 628 00:42:54,190 --> 00:42:55,970 We'll get the number of files. 629 00:42:55,970 --> 00:42:59,810 So , there are lots of things that we will use that for. 630 00:43:00,490 --> 00:43:07,510 Now that ampersand, and this is a good example of it, putting something in background. 631 00:43:07,630 --> 00:43:13,330 I like to use gedit, the graphical editor on Linux. 632 00:43:13,330 --> 00:43:20,190 Now if I'm on a command line, and if I say, you know, gedit, hello, whatever the file is. 633 00:43:20,590 --> 00:43:22,090 And just do that. 634 00:43:22,090 --> 00:43:27,350 The problem is, it's going to hang the command line until that command finishes. 635 00:43:27,950 --> 00:43:33,650 And so, if I remember, I will have the ampersand. 636 00:43:33,650 --> 00:43:37,750 And so it's going to star gedit and run that in the background. 637 00:43:37,750 --> 00:43:40,370 And so I get the prompt back in the command. 638 00:43:40,370 --> 00:43:47,790 That's just a little example of something that you might want to run in the background and not tie up the screen. 639 00:43:47,790 --> 00:43:50,830 Many other times you will be using that. 640 00:43:51,330 --> 00:43:53,690 So, what can be a command on Linux? 641 00:43:54,090 --> 00:43:55,090 Lots of things. 642 00:43:55,090 --> 00:43:57,250 A program can be compiled. 643 00:43:57,330 --> 00:44:01,410 It can be an interpreter, say Python, or many other things. 644 00:44:01,410 --> 00:44:02,930 You can even run JavaScript. 645 00:44:03,250 --> 00:44:05,010 So things can be a script. 646 00:44:05,530 --> 00:44:10,910 And they can all look the same and run just like it's, you know, command. 647 00:44:10,910 --> 00:44:15,310 So the command can be a file that is on the disk. 648 00:44:15,450 --> 00:44:17,950 It can also be built into the shell. 649 00:44:17,950 --> 00:44:20,310 We call the shell the command line interpreter. 650 00:44:20,310 --> 00:44:21,870 So it can be built in there. 651 00:44:21,870 --> 00:44:27,250 And we give you an indication of looking at, say, man built-ins. 652 00:44:27,250 --> 00:44:30,870 And you will see the commands that are built into the shell. 653 00:44:30,870 --> 00:44:37,470 For example, if you type ls for list cd, those are not programs sitting on a disk. 654 00:44:37,470 --> 00:44:39,190 They are built into the shell. 655 00:44:39,190 --> 00:44:41,940 But they all run as commands. 656 00:44:42,570 --> 00:44:47,130 So the commands are generally available system-wide. 657 00:44:47,210 --> 00:44:51,230 And they can be in any directory, okay? 658 00:44:51,370 --> 00:44:53,910 Now, you can restrict some of them. 659 00:44:53,910 --> 00:45:00,100 For example, the privileged commands, you know, some people might not be able to run those. 660 00:45:00,100 --> 00:45:06,680 And one of several ways they can be restricted from everybody running them, okay? 661 00:45:07,960 --> 00:45:19,980 If you try to do something on a Linux system and the command is not there, if you're on the internet, oftentimes it'll tell you, well, this is in such and such a package. 662 00:45:20,060 --> 00:45:22,940 You know, install this package and you'll get the command. 663 00:45:22,940 --> 00:45:24,700 So that's pretty helpful. 664 00:45:26,000 --> 00:45:40,800 And if you are the root user, running as a root and you put in something, command that's not there, say tcpdump or something, and it'll say that it's here, do you want me to install it? 665 00:45:40,800 --> 00:45:42,240 And you'll say yes or no. 666 00:45:44,500 --> 00:45:48,300 So Linux and available memory. 667 00:45:48,800 --> 00:45:53,120 Linux attempts to use all of the memory that's on the system. 668 00:45:53,120 --> 00:45:57,560 It tends to make, you know, very good use of it. 669 00:45:57,800 --> 00:46:04,700 Slowly over time, it will allocate memory to buffers and to cache. 670 00:46:04,840 --> 00:46:10,420 Now, the buffers are part of the virtual memory system. 671 00:46:10,420 --> 00:46:17,700 If you start paging, you will use some of the buffers, you know, to move program segments and things. 672 00:46:17,700 --> 00:46:30,660 The cache is simply an area where files and things, you know, you've run files, and it will keep the contents of them in memory. 673 00:46:30,660 --> 00:46:36,900 If you run that file again, then it doesn't have to read the disk. 674 00:46:36,900 --> 00:46:40,460 It'll just read it from the blocks that are in memory. 675 00:46:40,460 --> 00:46:50,380 So what Linux does over time is it slowly takes the spare memory and starts allocating it to the cache and to the buffers. 676 00:46:50,380 --> 00:46:53,520 Now, this is still available memory. 677 00:46:53,520 --> 00:47:02,200 If you load a big program and you need it, it's going to deallocate that in a flash from wherever it put it, and it's available to your program. 678 00:47:02,200 --> 00:47:07,560 So it's not memory that is wasted or unavailable. 679 00:47:07,560 --> 00:47:09,780 It's instantly available. 680 00:47:09,780 --> 00:47:19,860 The adage in Linux, you know, we should use all of the memory is a good thing. 681 00:47:20,960 --> 00:47:27,580 This is just a little example of the cache and the buffers over time. 682 00:47:27,720 --> 00:47:30,020 You know, you'll see that they grow. 683 00:47:30,140 --> 00:47:32,300 Now, why am I mentioning this? 684 00:47:32,300 --> 00:47:37,720 Now, it might not matter as much today, and it still might matter in some cases. 685 00:47:37,720 --> 00:48:00,600 Depending upon the way a Linux program looks at the free memory, you know, what functions are used to read it, it might say that it's low on memory because it's not telling you about the memory that's in the cache and that's in the buffers. 686 00:48:00,800 --> 00:48:06,800 And what would happen a lot of times is that, you know, you would have, you know, servers and things running. 687 00:48:07,540 --> 00:48:16,160 And you see the, well, the memory usage is going up, up, up, past 85% all the way up to 99%. 688 00:48:17,000 --> 00:48:19,120 And what happens at that point? 689 00:48:19,120 --> 00:48:22,400 You know, people start screaming and running and all that type of thing. 690 00:48:22,400 --> 00:48:27,180 And you look at the machine and it's like, no, the machine is not running out of memory. 691 00:48:27,180 --> 00:48:29,660 It's just, you know, it's just allocated this memory. 692 00:48:29,660 --> 00:48:34,020 And so when you say how much memory we have free, it's not telling you all of that. 693 00:48:34,020 --> 00:48:38,640 Now, the commands have changed where you can look at that and see that. 694 00:48:38,640 --> 00:48:41,140 In fact, you've been able to look at that and see that for a while. 695 00:48:41,220 --> 00:48:48,700 But the way that you can go in, you know, with the program to look at that, you know, there is a more modern way of doing it. 696 00:48:48,700 --> 00:48:50,100 And it's not a problem. 697 00:48:50,100 --> 00:48:54,340 But if a program uses the older way, then yeah, that can happen. 698 00:48:54,780 --> 00:49:03,440 And on the GitHub, there is a PDF that we have out there that talks about that. 699 00:49:03,440 --> 00:49:06,300 The programming that looks at that. 700 00:49:06,300 --> 00:49:11,500 But , you know, so when you see the memory going high, it's not necessarily a bad thing. 701 00:49:11,500 --> 00:49:16,040 OK, so compatibility of the different files and things. 702 00:49:20,560 --> 00:49:32,200 So when we have the USB drives and you use one by default, and what I list here is something, sometimes this catches me. 703 00:49:32,320 --> 00:49:34,780 And so it's like, you know, I want to back up something. 704 00:49:34,780 --> 00:49:36,800 And I'm moving it there. 705 00:49:36,800 --> 00:49:39,460 And as soon as it hits four gig, it stops. 706 00:49:39,560 --> 00:49:48,440 Well, that's because it's formatted as FAT32 and a file size is maximum four gigabytes. 707 00:49:48,500 --> 00:49:52,340 Now, you can have lots of space on there, but you just stop there. 708 00:49:52,340 --> 00:49:55,200 And so it's a fairly easy fix for that. 709 00:49:55,200 --> 00:49:57,700 And that is to reformat that drive. 710 00:49:57,700 --> 00:49:58,900 You could do it on Windows. 711 00:49:59,420 --> 00:50:01,720 Format it as EXFAT. 712 00:50:02,100 --> 00:50:07,440 And that's, you know, one of Microsoft's, you know, things, you know, Linux will read it usually. 713 00:50:07,440 --> 00:50:12,400 And if Linux doesn't read it, you can, you know, install the packages so you can read it. 714 00:50:12,400 --> 00:50:21,440 But what that does is to, you know, allow you, you know, allow you to use, you know, the very large USBs, you know, to store things on it. 715 00:50:22,520 --> 00:50:31,940 Also, on this slide, you know, we talk about the file systems of the different systems, the file types of the different systems. 716 00:50:31,940 --> 00:50:37,960 So, in Windows, you know, we see we have FAT32, NTFS, and EXFAT. 717 00:50:38,440 --> 00:50:43,780 When we go to Mac and Linux, they cannot read NTFS. 718 00:50:43,780 --> 00:50:47,340 So, they can read, you know, the FAT, the EXFAT. 719 00:50:50,820 --> 00:50:56,980 So, this slide gets back to some of the other things that we're seeing earlier and that Linux is a modular system. 720 00:50:56,980 --> 00:51:02,980 And we talk about some of the things that are modular in the Linux system. 721 00:51:03,800 --> 00:51:09,240 So, all of these things can be changed out and, you know, set up differently. 722 00:51:09,240 --> 00:51:10,340 You can do that. 723 00:51:10,340 --> 00:51:15,380 Usually, you're not going to do that on your own distribution, but you might. 724 00:51:15,380 --> 00:51:24,680 You can roll your own distribution and you will decide, you know, which kernel version, which type of bootloader that you use. 725 00:51:24,680 --> 00:51:26,640 There are several of those. 726 00:51:28,040 --> 00:51:36,600 The package manager, we talked about that, you know, whether it's going to be Red Hat, whether it's going to be Debian, but you can, you know, select all of these things. 727 00:51:37,760 --> 00:51:43,040 So, Linux and viruses, you know, people say that Linux is more secure. 728 00:51:43,040 --> 00:51:48,440 It might be, and I think that's kind of a debatable type thing on it. 729 00:51:48,440 --> 00:52:02,840 But one thing that I do tell people is that a non-privileged user in Linux typically will not be able to write to as many system areas, as many programs and things. 730 00:52:03,060 --> 00:52:10,840 Unless an organization restricts their Windows computer, people can oftentimes, you know, overlay stuff and whatnot. 731 00:52:10,840 --> 00:52:17,240 And, you know, that's how malware can get attached to the system. 732 00:52:17,240 --> 00:52:26,700 But if it cannot write to, you know, a lot of the directories and things, you know, that kind of cuts down on a lot of that. 733 00:52:28,100 --> 00:52:40,460 We mentioned su and sudo because when you install Linux, you do not necessarily have a root password that you put in there. 734 00:52:41,200 --> 00:52:47,780 Windows... Linux knows the root password, but it does not tell you that by default. 735 00:52:47,780 --> 00:52:55,840 You can get at it, but you're the first user who installed it and you have rights to run that su and sudo. 736 00:52:55,840 --> 00:52:58,000 Su stands for switch user. 737 00:52:58,280 --> 00:53:02,440 And sudo means switch user, do something. 738 00:53:02,440 --> 00:53:04,180 And you can set up files and things. 739 00:53:04,180 --> 00:53:05,660 And we list all of that here. 740 00:53:05,660 --> 00:53:15,120 sudoers that has, you know, the people who can run various, you know, privileged commands on the machine. 741 00:53:15,620 --> 00:53:21,600 I list a very fun and favorite command here, dd. 742 00:53:21,600 --> 00:53:25,280 It's questionable what dd actually stands for. 743 00:53:25,280 --> 00:53:29,440 I think some places like Wikipedia might say disk duplicator. 744 00:53:29,440 --> 00:53:32,920 That's not exactly sure where that comes from. 745 00:53:32,920 --> 00:53:39,680 But dd is very handy because you can copy anything with it. 746 00:53:39,700 --> 00:53:42,140 Everything is treated as a file. 747 00:53:42,140 --> 00:53:45,480 You can copy entire disk with it. 748 00:53:45,480 --> 00:53:48,160 You can backup disk with it. 749 00:53:48,160 --> 00:53:59,360 In the syntax that we have here, we see that we have a disk and we can back it up and we can compress it as we back it up. 750 00:53:59,360 --> 00:54:10,840 Compressing takes a bit longer, but, you know, you can take the contents of, you know, I have a computer here, I believe it's 256 gig SSD. 751 00:54:11,160 --> 00:54:20,920 And, you know, when I run dd on it and back it up and compress it, I think it's about 15% of the size. 752 00:54:20,920 --> 00:54:25,820 So it's a pretty handy command for doing that. 753 00:54:25,820 --> 00:54:28,400 Of course, this works on Windows partitions. 754 00:54:28,400 --> 00:54:32,980 You can backup something, load it, back it up, that type of thing. 755 00:54:32,980 --> 00:54:36,780 Okay, we're getting to the final stretch. 756 00:54:36,800 --> 00:54:43,200 So I list some things that are awkward in Linux, you know, awkward or buggy. 757 00:54:43,620 --> 00:54:56,320 One thing that I will highlight Fedora because you may get caught trying to upgrade and you want to make sure it doesn't get too far behind before you start upgrading. 758 00:54:56,320 --> 00:54:59,100 We just, you know, highlight that. 759 00:54:59,660 --> 00:55:08,820 So in summary, we've listed, you know, how Linux got its start and it came from Linux. 760 00:55:08,860 --> 00:55:15,760 And, you know, you see some of the differences and things between Linux and the Windows systems. 761 00:55:15,800 --> 00:55:18,060 Okay, are there any questions? 762 00:55:22,450 --> 00:55:38,030 Okay, so here is where you can find the slides and other information on GitHub for installing Linux, backing it up, and doing things so you can roll your own installations of that. 763 00:55:39,390 --> 00:55:43,190 And this information is available right now. 764 00:55:43,430 --> 00:55:45,270 So otherwise, I appreciate your time. 765 00:55:45,270 --> 00:55:46,290 Thanks.