 In this video we're going to talk about some of the basic commands on Linux or Mac OS or any Unix-based operating system that tell you information about your system. I'm going to do a video on file writing and stuff like that pretty soon, but I just wanted to put some commands out there that you may or may not know and some of the things you can do with them to get file information or system information. Okay, let's start at a very, very basic level. Let's say, well, what's the time? What's our time and date? Well, in the status bar I have my time and date, but the real way you get that is typing in date. In fact, my status bar is actually built off this command. Date at any point in time will give you day of the week, day of the month, all that kind of information of when exactly you're writing. You can look at dates manual and it will actually show you can... You have a lot of fine-grained control over the kind of commands you can run depending on how you want your particular format. If you want to say, oh, give me the current century or something like that, that's an option. In fact, I mentioned my status bar has a date module. It runs a slightly different date command. Let's look at that briefly. So I'm going to copy this over here. So what this date command will do, and I'm actually going to get rid of this icon thing because it isn't relevant, is it puts the... It basically says, okay, date. I want you to give me the date, but give it to me in a different format. For example, give me the year first, give me the month after that, then the day, then the day of the month, or day of the week in parentheses, et cetera, et cetera. So you actually have a lot of control in how date runs. And if you have a different language or a different locale, date will automatically have a slightly different format. So in addition to date, there's also... Let's say you want to know, okay, what day of the week is the 30th this month? Just run cal and it'll tell you, okay, it looks like it's Tuesday. It'll automatically say for your month and day, month and year or whatever. So you can run Cal, or you can run Cal with a three option. It'll give you this month and the month before and after, if you need to know, okay, when is the 15th? Okay, it looks like the 15th in July is on a Wednesday, okay? And in fact, Cal is pretty cool because you can actually just look at any date in history. Let's say I want to know about June in the year 546, okay? It's going to tell you, oh yes, I needed to know that the 8th was on a Friday or something like that, all right? It's a nice little tool, okay? So that's Cal. So date and Cal, let's talk about more system-specific stuff, okay? Let's say I want to know the remaining space on my hard drive, okay? The way you do that is you use the command DF. So if you just run DF by itself, it's going to print out this. It's going to print out all your partitions and other, you know, virtual mounted stuff or whatever. And it's going to show you, so here, for example, is my home directory. It says it's 87% full. And then it gives these scary amounts that show you, you know, how much space is used or available. Now, by default, this is not very readable, but DF, thankfully, like many other programs, has the H option, which means human readable. Whenever this goes for most commands in general, if you run it with H option, you'll see that, okay, we got the same information. But now, oh, I see that home, for example, I have, you know, 850 gigabytes total. I've used 69.8 gigabytes, and I have 109 left, okay? That's a nice, it's a little bit more convenient to run DF with the H option. So that's a very nice tool if you just need to check it. I've used this in scripts. I've, you know, to get some information about a particular partition and test and see different things. So that's a nice little tool. There's a corollary. Actually in addition to use, you know, again, H doesn't just don't just exist on DF. There are some other commands. Let's say, let me actually bring up a bash prompt over here or something like that. Well, I'll just bring up bash here, it doesn't matter. So by default, if you run LSL, it's gonna print out, it's gonna print out your, you know, the file size of all these things. But it doesn't, by default, contain the human readable format. So you can give it the H option as well, and it will do the same. A lot of distros will actually do this automatically. They'll automatically, you know, make LS human readable, but not all of them do. Okay, so back to, so we talked about DF, which gives you your partition information. DF has a counterpart. DF, again, is looking for free space. You can also use DU, which looks for used space. You might think that that, isn't that the same thing, but the opposite. Well, DU, what you do is you can run it on an individual file. I'm gonna run it on this screencast file right now. This is the file that I'm actually recording right now that you're seeing now. And so if I run DU on it, it'll actually show me that file size. Or, of course, I can give it the H option and it'll say, okay, that's 2.5 gigabytes. Okay, great. Right, so I need to know. You can also run DU on, you know, directories or something like that. Let's say I run DU with the H option. I'll run it on, let's see, work, okay? So my work directory, and it'll actually go through that directory. It'll say, okay, the whole thing is 2.3 gigabytes. Inside of it, you have these different folders that have different sizes, right? And they all add up to 2.3. Or you can actually even give it the A option and that'll list out all the files inside of it. Very handy for doing different things. And this DUA cannot actually be used to sort of search for files and stuff like that if you don't like the syntax of the command find. Okay, so there's that. Now let's say you want to look at what programs are running on your machine. The most simple command for that is PS. Now if you just run PS by default, it's just going to show this and you're like, hey, what's this? I don't care about this. Now PS has so many options to give it. You might actually want to look at its, you know, document, I was about to say documentation, just type in man PS. But usually you run PS with, you know, let's say A and X. And that'll actually list out all the programs that are currently running. For example, Bash is running, MPC is running, that has to do with my status bar. FFmpeg is the command that's currently doing the screencast, ST is my terminal, LF is my file manager, it's pulled up on another window. So you can see all the programs running DWM, my window manager. Now if that's a little confusing, it has a bunch of output here. See some of these are really long. You can actually put the C option as well and that will make it a little bit easier to read. Now PS is also one of these programs that has a whole lot of output. And when you have a whole lot of output, sometimes you want a different way of looking at it. You might want to pipe it into another program that makes it easier to read. Like for example, less allows you to just scroll up and down easily, sometimes a little easier than doing it in the terminal. You may also, let's say you're looking for one specific program. You want to see if you're running MPV, okay? You can actually pipe that into grep and then run MPV on it, okay? And it's going to find, okay look, of all this output, search for the line, what grep does in case you don't know anything about grep. I'll do a video on piping and grepping later. But grep, what this PS command does is it finds all that output we just saw, and then it sends it to grep. And what grep does is says, okay, you give me something to look for and I'll return all the lines with that on it. So we see this is a way of saying, okay, look, MPV is actually running on this machine. And that's my little face over here, it's running an MPV. Now, an easier way to do that, if you want to know more system commands for checking system processes, if you just want to check for one, you can actually just use PID of, PID of MPV. And that'll give you back a little number. Now what this did, so let's say I run it on a program that's not running right now, let's say Firefox, okay? I'm not going to get a number. Now what is this number? This is actually the process ID, that's why it's called PID of, get the process ID of MPV. Meaning, if I run the command kill on this particular process ID, you'll see that my face now disappears, okay? That's what that does, I'm going to bring myself back. So, but PID of, just using PID of to find numbers, even if you're not going to use them is actually pretty useful if you want to, in a script, just check to see if something's running. You can also use PGREP, PGREP is actually a little, it's a little bit slower sometimes, not all the time, but PID of I find a little more reliable. Okay, so we talked about PSAX, let's talk about some cleaner commands than that, that's the most basic one. Another thing you could do is run top. Top is a command that will list out, it gives you a full screen sort of visual look at all the processes that are running, it'll give you their names over here, it'll give you who's running them, most of them are either Luke or Root, so actually all of them are Luke and Root because it's the only thing going on. And I'll actually show you how much of the CPU and memory all of these processes are running. And notice right now, FFmpeg is taking up most of my CPU cores, you know, basically two cores. FFmpeg is the thing, again, recording this video. So, you can quit out of that with Q. And now, if you don't like top, because it is a little ugly, a lot of distributions will also come with H top, which is a more colored variety of it, which can be a little bit more convenient in some cases. Or, I mean, there's actually a cottage industry of top commands, like for example, I have go top. Go top is very nice. Actually it doesn't look that good when my font is big, but it shows you your CPU usage, memory usage, network usage. Go top is definitely not gonna be installed on your computer unless you know about it. But top is the most basic command, just know that. Okay, so additionally, let's say we forget what operating system we're running, okay? Well, we can use the UNAME command. And it will give you, technically, it will give you your kernel, okay? If you look at UNAME's documentation, it has all these different options. So, S prints the kernel, A prints all system information. So again, S prints the kernel, which is Linux. If you want all system information, you get the kernel name, your current computer name, the builds and dates, and you have your official operating system name, which, yes, is GNU slash Linux for anyone who was debating about that. They do have a specific operating system option, yeah. Just a double check. If you wanna know if you're running GNU slash Linux or if it's Linux or GNU slash Linux, just run UNAME with the O option and it's gonna say GNU slash Linux. So, I'm sorry, the FSF was right all along. So there's that and let's see what else. So I talked about DF, DU. I think that's about it for this one. One last one I will give, just because I don't know if this is a common question. How do you find your IP address, your local IP address? Well, you basically just type in IP adder, okay. And it will give you your network devices, your ethernet device, your Wi-Fi device. And if you're connected to the internet or your local network, it will give you this. This is your current IP address, which contrary to popular belief, if you have someone's local IP address, you cannot hack them, okay. That's actually the funniest thing in videos when people see like, dude, oh man, I saw your IP address is 127.0.0.1. I'm gonna hack you, man. That's just like so, dude, cringe. Or even worse, even when I showed my servers IP address, people are like, dude, I have your servers IP address. What are you gonna do? I don't know, you're gonna log on to my website. You're gonna look at my webpage, I don't know. All right, here's a hack tip, guys. If you wanna find the IP address to any website, just ping it. Oh man, I can hack you, man. Anyway, so that's about it. I don't know how long this was, but I'm gonna do another video, two videos in mind on shell scripting and bash, or not even shell scripting yet, but really shell and bash basics. I'm gonna do one on editing files and then one on editing streams and piping and all that stuff that newbies don't know that they need to know, but they definitely need to know it to be able to do stuff good. So anyway, that's about it, and I'll see you guys next time.