Linux Terminal Basics 3 | Paths, Storage and System Monitoring

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
greetings and salutations and welcome to video number three in our series called Linux terminal basics in this series we're taking a look at some tools and concepts that will help you to become better at administrating Linux systems whether it be your home desktop or a bunch of servers in the cloud we are assuming that you already know a little bit about the terminal that you can navigate maybe you've run some commands maybe you've even edited some files thus far in video 1 we have looked at text in video 2 we looked at working with files and this time around we're going to talk about executable programs and paths and we're gonna talk about storage and we'll take a little bit of a look at how to keep an eye on what's going on in your system we're gonna look at gathering information and system monitoring so we've got a lot to cover but before we get into that I want to say thank you very much for all the kind encouraging comments that video number one and video number two have already gotten a lot of folks had nice things to say and even added useful information to the conversation so thank you very much so the first thing that we're going to talk about is executable paths what is that well it is where the system looks to find all of the programs that are installed on the system and if you want to know what your path statement is just type in echo dollar sign and then the capital word path all in caps that will read the variable that's stored in the shell environment that contains this information what is a variable well it's just a chunk of information that you want to have sitting in memory when you log into your system a lot of these variables are generated by the system and programs that run in the shell or even on your desktop can draw from these variables and get all kinds of information about the computer that they're running on and information about you as a user so if you want to see all of that just type in the environment command and you'll see a big long list of them here I mean some of the stuff it's pretty straightforward like let's see here we've got user well that's Joe and then up there there's username that's Joe as well so somewhere in here is your path statement and that's what we're going to be talking about in particular today all of this is generated by the system as it boots up there are configuration files in the slash et Cie directory and in your home directory where this is all kept and so what we're gonna concentrate mainly on is just we're gonna concentrate on your local bin and we're gonna talk about one location where programs are stored called USR slash local bin and these are important because this is where you would put programs if you created them yourselves we're talking about scripts we're talking about any code that you would compile and we're talking about just anything that you're working on that's yours for that moment so I have created in my home directory a directory called bin and in a boon to and in many other systems Debian as well if you do that when you reboot the system when you log back in it goes oh you have a bin directory in your user folder let me add that to your path and let me make that the very first place that I look for programs that way you can have a program that you're working on that is actually installed somewhere else in the system and they both have the same name and instead of you having to have a different name you can have the same name and the system will look in your local bin directory first and it won't pay any attention to anything else later on in the path statement that you see up there so what are all of those different directories well that's where the package management system on your system on your Linux computer puts different applications we don't throw them all in one basket we put them in special directories that kind of signify what they do so if you see s bin for instance that's going to be something for the system administrator to use not necessarily every user on the system anything that goes in the USR directory in under bin or local bin that would be something that's available to everyone anything that goes into your local bin directory that you created yourself that's just yours and nobody else can use it so let's put that into action and see how it works so you'll notice here that I have a script already in here called hello Sh it's the same one that we were working on in the last video remember we just changed the permissions on it to get it to run I never actually ran it if I just type in hello first of all if I just type in hello dot Sh and I try and run it in my home directory like this it says the commands not found reason why it's not in this path anywhere that you're seeing up top it's not in any of those directories so the system goes I don't know what you're talking about that is a security feature if you are allowed to just execute any type of executable script program whatever that happens to be in your present working directory then somebody could use that against you they could slip in a Trojan horse they could slip in something that looked like LS but it wasn't so when you go to list storage instead of running the LS command what are you running you're running whatever they want you to that's bad so that's why it's done that way you can if you want to go figure out how to add your present working directory to your path statement it is possible to do I don't recommend it it's not a good idea but most people would not want to do that anyway but it's Linux Linux will let you do whatever you want hey you can delete the entire system if you want to go right ahead knock yourself out have a good time people have done it so how do I run a program that is not in a path stated place in in up there let's say that I'm just writing a script and I just want to make sure it works all you got to do is tell the system where it is so the first thing that we do is the dot which presents the current directory and then we say in that directory that's what the slash signifies that tells the shell hey I want you to do something with it in the directory or if we use that with the copy or our sync commands or the move commands that's telling the system I want you to put it in this directory that's what that means and then we can type hello and look I can autofill it that time I can use the tab key because the system knows where to look for so if I can autofill it it's gonna run it there you go hello world it works so if we want to put it somewhere where we can use it elsewhere on the system then what we can do is just let's just move it we're gonna move hello world and we're gonna put it in my local den like so let's see if the system finds it now yes it found it well here's the thing if it's in my local bin I'm the only person that can actually use it so if I try and do it as root user it probably won't run nope can't find it why because it's in my local bin directory and that's not in the root users path statement which is different from yours because when you log in as root you create an entirely new environment and you change all of those variables and some of them are different from yours the user name is different everything's different and the path statement is different as well so if we want to use this program and have it be available to everybody on the system let's say that you have a system and you got five six user accounts on it and you want everybody that can log into the system to be able to get to a program or script that you're running then where would I put it well where we would put it would be user slash local slash bin and we can just do that really quickly with the move command once again so we're going to move then hello to slash USR slash will slash then but it's not gonna just let me do it it's gonna deny me the ability to do that why because that is not in my home directory I don't directly have permission to do that so we'll just do that as the root user cuz the root user is the only person that can move files into other parts of the system outside of your home directory the only places that you have absolute access to are the temp directory and your home directory so let's go ahead and do that now that I have put that there if I do sudo hello it'll run and it didn't even prompt me for a password because the sudo timer was still on so you get the idea gang that little hello world script it comes quite handy for demonstrating stuff and that's pretty much all I'm gonna talk about about paths in this video it's just an introduction there's a lot more to be said you can change your path if you want to it's contained in configuration files all throughout the system now where what I will show you is if you create your own bin directory sometimes you might run into a situation where the system doesn't automatically add it you log a you look logout you log back in and it's not seeing it and you're going well what's wrong and that's because every now and again it doesn't work when it goes to add to the system and here's how you fix it so that command is actually in two places let's clear the screen and what we want to do is we're going to read with less that read command wouldn't work that's the typing and talking at the same time makes you do stuff like that so we're going to look at a program which exists in your home directory called profile I'm a set program but it's just a it's just a configuration file and we're looking at it with less and you see that at the bottom here the first thing it does is it looks to see whether you have a file called bash RC that's what that little chunk of code does right there and if it's got it then it reads it into the system and then it looks to see whether you have a home slash dot local slash bin and then it'll add that to the path if you've got that I don't use that I just use the been directory that is stated right there once in a while especially with Debian I've noticed for some reason another Debian will run bash RC and then it will miss this piece of code right here this part so what you have to do is you have to manually add it to the bash RC in a boom too if we look at the bash RC file you'll see that at the bottom it's already added so I'm just scanning down through here and either is or it is not I think it's in here somewhere but maybe it's just the way the bash RC file works in a boon to that it doesn't cause an issue and it does it in some Debian distributions I guess I don't know because I'm not seeing it here I don't think it's added but either way if you see that it's in profile and then you see that it's not in bash RC then what you can do is just add it that's what I do on Debian system so I will open up profile and I will go ahead and copy this part right here all of this text so we can copy that and just we'll just copy it and get out and then we can Nano like so go all the way to the bottom and then we can paste that in like so now we don't need to do that because it works fine for us in a boon too but like I said in Debian sometimes it doesn't and so I'm gonna go ahead and just get rid of that because we don't actually need to use that and of course I didn't even need to backspace through all of that all I got to do is exit without saving changes which is what I should probably do anyway right there you go so the next thing that we want to talk about is working with storage on your system and by the way yes there's a lot more that goes into paths and working with paths and understanding paths that's just an introduction you can go off and learn more on your own if you want to so let's talk about working with storage in Linux we don't have ABCs for our hard drives we don't have drive icons we have just devices that are mounted somewhere in the system and the system does this this way because as far as UNIX and Linux are concerned everything is a file remember we talked about working with standard in and standard out before and how that really were just moving data from one place to the next and that's all the system ever does well guess what it sees all of the drives on your system as nothing more than files so let's see where are all of these places mounted - well they're in a directory on the system called dev so if we do an LS and then we do this you see there's a whole bunch of stuff listed here that's in the dev directory these are all devices that are hooked up and if you know what you're looking for you can kind of know what you're looking at so here we have ttyS well these are terminals and believe it or not we got a bunch of terminals spun up on the system at any given time and if we look under s let's see see the s DS here right here this is your hard drive that's your storage devices SD a SD one SD - those are parts of your hard drive SD stands for scuzzy device there's a lot of other stuff in here that might look a little weird like here's one we're gonna look at here in a little while zero what is zero what is that in the dev directory your keyboard is in here everything is in here somewhere it's mounted into the dev directory and the system simply sends data to it as if it was sending it to a file basically that's how it works basically that's how it works it's not exactly how it works sometimes it doesn't work that way in modern Linux systems but it's the concept by which the thing is supposed to being figured out I guess if that makes any sense does that make any sense I doubt it anyway we're gonna look at LS block right now because that will tell us the storage devices that are in the system and where they are mounted within the system so remember our SDA in dev well there it is right there this is our main hard drive on the system and on this hard drive I've got three partitions so why don't you let's see get this to highlight the way I want it to so we go to SDA like here and there we go trying to get that to highlight so this part right here is really what we're interested in SDA that's the hard drive SDA one is the first partition SDA two is the second partition SDA 3 is the third partitioning you notice that they're mounted in different places SDA one contains the system so SDA one is mounted at the slash which is the root of the filesystem and then the next one we have a partition called vm and that partition control contains virtual machine images and then i have my home directory which is on SDA three the third partition on the disk so what is all this stuff up here well the stuff that says loop these loop file systems here those are Lubuntu snap packages so they run within their own little storage container to keep them secure that's how it works and then here down here you see an SRO whoa what's that that is the DVD Drive in my computer so if I put a disc in there it'll pop up as s.r.o one or whatever however that shows up so that's useful information but how can we manipulate this and use it to our advantage well we can also gain information about what's mounted in the system just by running a command called mount now it doesn't give it in the most pretty way but now we've got more detailed information here so let's go down here and find where we have our hard drive mounted a whole bunch of information let's see so we'll just scan down here it just dumps it out on the screen all right here is SDA - and SDA 3 and you will see that in this line right here it tells us that SDA 3 is mounted on home the type is ext4 that's the file system and this part right here are the rules by which it's it's mounted and so it's read readable writable and then we have a couple of options for ext4 and that by the way is listed as default so how does it know where to mount things what's telling it to do that well in the case of storage devices and hard drives we'll be looking at a special file called FS tab so let's clear the screen and we will take a look at FS tab now we've seen this file before in earlier videos let's talk about what the information in it means when the system boots up the kernel looks for this file in the e.t.c directory as soon as it figures out that where its root filesystem is that runs the kernel and then the kernel looks for this information at boot time to say okay what devices do I need to attach to the system and where should I put them well the first one of course is going to be the first partition on that disk and it's SD a1 we're mounting that as root right there then home that's where all of our home directory files live and then I have added to the system at installation another partition called VM and then finally we add a swap file and swap space can be one of two things it can either be a special partition on a hard drive or it can be just a file that lives in the system a boom - as of what was it a boom - 1604 switched over at the war 1770 no for I think it was I might be getting that wrong they switched from creating a special partition on the drive for swap and started creating a file for swap and that needs to be mounted somewhere in the file system as well so this basically goes and looks for a file called swap file and then mounts it up with those rules and that's how the system knows where to put things it might cause a little controversy here but I am gonna mention because I got a comment on this the other day somebody said well if you have a lot of memory in the system you don't need to run swap that is not true for those of you who have heard that please don't run your system without at least a little bit of swap it's not that big a doubt a big a deal to set aside a little 2 gigabyte swap file to have the kernel have some scratch space to work with swap is virtual memory if for some reason your system runs out of physical memory wants to use swap to keep running and even if you have 64 gigabytes of memory in your machine you could have a program with a memory leak and it could use up all that memory and then the system would just freeze and becomes unstable so it's a good idea to leave a little swap behind and some programs that run on your system actually access swap independently they use it as well so you do need to have a little bit don't believe the hype all the people saying you don't need any swap you need a little bit okay so we've looked at where things get mounted and how that works so another thing that we want to talk about is where you mount things within the file system if you're doing it yourself now we're going to get into actually getting something done with this command and not just looking at it and go home that's interesting so if I list all the stuff in the root directory we've got a couple of interesting directories in here the first one is cd-rom and that is old school that goes back a long way there's nothing in there that is where if you had to manually mount a CD or a DVD that's where you could put it so that you could work with it and you can do you can put that in there manually the other one that you'll notice is that we have a directory in the file system called MNT it's right there there's nothing in there either that is where the user can mount their own media so let's see how that works let's do it let's let's actually create some media that we can mount into mount and then add files to it does that sound like fun in other words I'm going to demonstrate by doing so the first thing that we're gonna do is we're gonna put a USB Drive into the system I'm gonna plugging it in right now in the front of the machine it's a little 8 gigabyte USB stick and it's not empty it has other stuff on it let me go ahead and clear the screen system should have found it by now let's go ahead and run the LS block run it correctly and what you get here is now you'll see that we have an S DB which is my little USB drive that I have put into the system it's mounted at media / Joe / linux mint 18.3 cinnamon 64-bit so that what what that tells me is is that that is a Linux Mint install disk well I'm not running Linux Mint 18.3 anywhere I don't need this disk anymore so the first thing that we want to do and what I like to do before I try and format a disk is to blanket I want to make sure that there's nothing left of the old partition table that can mess me up so let's go ahead and clear that the command we're going to use for that is DD and we are going to put in the input file equals and here's where this comes along let's say dev 0 that's that 0 so what is Deb's 0 dev 0 is nothing more than a little virtual file that spits out zeros constantly it's a 0 generator that runs in the system when you ask dev 0 for data it just spits out a stream of zeros there's another one in there called random and that just puts out total gibberish but I like to use zero because I just think it's cool ok so we're using a program called DD to do this DD is a dangerous program be very careful I have a whole video up about DD and you might want to go check that out so where are we going to put our output file we're going to put that on dev s dB that's our drive remember that the system treats everything as a file so we can make that pretty easy but we can use that to our advantage in this case now if I try and write to that since dev slash s DB is in the system part of the system that's owned by the root you it's not gonna let me so we have to do this as pseudo before I hit enter on this there is something that you really need to understand and that is that DD is extremely powerful it will erase your hard drive it will erase your system drive if you get the wrong arguments in it be very sure about what you're doing before you use this so right now the way I have it set up is if I just turned it loose as DD then what it would do is it would write zeros until it ran out of space which is a really good way to blank a drive if you want to completely blank a drive that's not a problem but I don't want to do that I just really need to wipe out like the first two gigabytes of space on the drive and that will get rid of all of the partitions and the old journals and everything from the file system right so to do that I'm gonna give this a block size and we're gonna call it 100 to 4k so basically the each block size is going to be one megabyte and then how many of them do we need well I want two gigabytes so the count will equal 204 8 24 8 so what that's going to do is write 2 gigabytes of nothing but zeros directly to that drive go and away she goes and it said it did it really quickly but I'm telling you right now it really didn't do it it's done it to memory and what's on the drive is actually still there now this is something that you can run into and in a case like this I'll show you a command that's very useful and that is sync what this does is it tells the system hey actually write it to the drive take all of the information that you have sitting in memory and the buffers and go it on the drive we'll look at buffers later on in this video by the way so I'm gonna go ahead and sink this now it's actually gonna write 2 gigabytes of data this may take a little while so I'm gonna pause the video that actually took it a little while to do we've gotten everything all synced up so if we run block again looks at the block storage we now see that s DB has absolutely no partitions on it whatsoever so we have in essence a blank Drive now it's not really blank we've just wiped out the first two gigabytes on the device but it's enough for our purposes and probably not enough for like the government you probably have to wipe the whole thing several times but let's go ahead and now put a partition on there and we are going to format the drive so we will use F disk to create partitions and we need to tell F disk exactly what drive to look at so we will call it dev SD B and we will run this program drive does not contain a recognize partition table that's exactly what we want to see let's go ahead and look for M for help so you guys get some ideas of some of the commands I actually have done this so many times that I don't even think about it what we're really worried about down here is that we create a new partition table that's right down at the bottom and if we use G it with the F disk here it'll create a GPT partition table that would be very useful for a very large hard drive if it was like more than four terabytes but this thing's 8 gigabytes it's very tiny so we're gonna use just a good old thoughts partition table that's not a problem so we just label O or just put in Oh a small o create a new Dark DOS partition table with disk identifier well absolutely it's done and now we need to create a new partition in that so where do we do that well let's see it's up here it's in here somewhere it'll tell me how to do that let's see we delete a partition with d so we add a new partition within so we're gonna add a new partition and we are going to go ahead and do a primary partition remember we're dealing with old daus so we have primary and logical in this case like I said it's 8 gigabytes we need one partition and it will be primary it will be partition 1 absolutely and we are going to use the first available sector there that's fine for this it's plug and play storage gang it doesn't have to be perfectly aligned like a solid-state drive or something like that we're going to use the whole space so yes and now it's Linux and the size is 7.5 gigabytes so we are all done now and what we have to do now is write it so we type in a W the partition table has been altered we've created the new partition table and we're all good to go and it dumped us back out to prompt so now we have if we go back to LS block again we've got a new partition on that disk and it's 7.5 gigabytes which shows that it's the whole thing so now what we got to do is put a filesystem in there that has to be done as root user and the command is make FS and we need to tell it what type of file system we want and at this point we could use fat32 or NTFS if we wanted to make this compatible with other devices but for today's demonstration I want to use the standard Ubuntu default file system which is ext4 ext4 is my favorite linux native filesystem even over file systems like butter FS and ZFS and x FS it's just a good all-around system one of these days I'd like to do an in-depth video all about ext4 and really get down into the nuts and bolts of it and show you guys why I like it so much but that's I don't know how many people would woman about that I mean that's geekdom to a high level so now we got to tell it where we want to create our file system and we want SD be one I always move a little slower and i know i typed slow anyway but i always move a little slower when doing stuff like this because if I would put SD a 1 I could wipe out my system which is always a good idea to use LS block to figure out exactly what you're doing ok so let's go ahead and put the X t4 in here and it is writing out the information right now this will just take a couple of seconds for this to do this of course because it is a little plug and play drive it's one of those really cheap drives you pick up at like the drugstore it takes a little while to actually write to there they're very slow it's done and so now we have our new file system on the drive so in order to use it we're gonna have to mount it so we will melt we'll do it as route mount 2 and we are going to use the mount command and we are going to put and we want it to mount it it MNT which is that space that I showed you earlier it's an empty directory and that's exactly what this is for and it should be there so we will now CD to MNT and list the storage oh-oh-oh see did you see the mistake I made I bet you saw it before I did that you saw it before I did so he mounted the route for a drive on SDA into mount we need to kind of fix that so let's CD to get out of that and we will sudo you mount like that okay now let's do that one more time let's run that mount command and get it correct now I always leave these mistakes into my videos because you know why you're gonna make them too you're gonna do exactly the same thing and so therefore I leave them in now we can change directory to mount and we have a directory in there called Lost and Found which was created by the system when we created the ext4 file system there and that's it so let's see if we can actually do something here let's create a file we'll touch a file and call it test Oh I don't have permission to do that well I'll tell you why I don't have permission to do that I created it as the root user remember we used sudo so guess who owns this drive the root user so I can't actually write to it which makes it a little bit on the useless side doesn't it we can fix that it's no big deal there's two ways to fix that we could make it where we own the drive and so nobody else on the system if it's plugged in could have access to it that makes it more secure or we could change the permissions on the drive so that it's still owned by root but then everybody could use it if it was a drive that I was permanently adding to the system and all of the other users would have access to it they'd be able to create files that's probably what I would do I would let the root owner use it and then or still own it and then I would actually make it so that everybody could have access to it but since this is a drive that only I'm going to use I'm gonna take it in and out of the machine I don't want anybody else to really use it I'm gonna change the ownership of the drive so how do we do that well we use to change own command now we've talked about changing the mode or the mod change mod right I don't know what that was sudo change own and then we're going to change it to Jo for the user and Jo for the group just separate those by a colon remember that's how it looks in LS when you do a long listing that's why and then we'll just do /mnt it is not going to be MNT the directory that's in the root filesystem what it's going to be is the drive itself so even if I remove the drive and put it back in I'm still gonna own it so let's go ahead and do that and now what I should be able to do is CD into MNT and let's see where's touch test right there LS guess what yeah now I can create the file and I can remove the file test so I have access to that drive I have created a new drive when you're done messing around with anything that you mount on the system you want to unmount it but you can't do it if you're actually in the directory that you're mounted to so if I try right now to do sudo you mount dev SD d1 which is another way to do it before we did it by doing the directory it was mounted - it's gonna say I can't do it let's see it's busy it's busy because we're in it so get out of it and now we can run that command once again and it'll do it we could have also done MNT so you can unmount the the drive itself the device or you can unmount the target either way as long as you're not currently in that directory it's not a problem and of course it's not mounted so if I plug this into my system and I'm running a desktop environment it's automatically going to be mounted most desktop environments take USB sticks and they mount them in the media directory or in the Run directory in the case of arch and manage arrow somewhere on the system and then it pops up on the desktop as an icon or in the file manager and you can click on it and play with it so that's how that works now all of that that I just showed you there are some graphic tools that we can use to do that so let's take a look at those real quick my favorite one to work with for drives on systems is known disks so it would be helped if I would spell that correctly and I can see the comments coming on that misspelling [Music] anyway this is a program called disks and it either comes with most distributions or you should install it because now we can do all of this just from a menu if we wanted to so if I plug this drive back into the system right here you see that it pops right up it found it and I go in here and it says it's the xt4 and then I can unmount it by clicking the little stop there I've unmounted it and if I want to reformat the drive then I just come up here to the menu and I can format the disk which creates partition tables or I can format the drive with ext4 if I want to take some time play around with disks another tool that is generally not shipped by default within the distribution but you will most definitely find in the live environment so in other words when you first boot the machine off the live environment you're going to have this program and then once you install it it'll go away is a program called gparted now we used parted parted is a program that creates partition tables and partitions we didn't use that we use def disk and make FS those are actually even deeper system type programs than part it is but gparted which I have installed on this computer is just a graphical representation of parted and there you go and then parted you have to run parted as a root user it doesn't let you and it's lovely because it gives you graphic representations of all of the drives on your system and then you can create new partition tables stuff like that very useful program so you can pointy clicky you don't always have to do it just by commands at a console or terminal whatever you want to call it the thing is about that though is that you might be logged in to a machine that doesn't have a desktop environment installed if you're working on a server if you're using SSH to talk to another machine it's good to know how to do all this so do some more research look around find out more about mount because it's a very useful tool to know about in the system and how you can manipulate storage yourself final part of this video we want to take a little time to talk about tools that you can use to figure out what's going on with your system and just kind of look and play around and see what you can learn and also you would probably find a lot of the more advanced tools useful for doing things like killing programs that are misbehaving if something hangs up you might want to jump in and get rid of it and I'm gonna show you how to do that in here as well so the first thing that I want to show you is just a couple of real quick commands that you can use to just check and see what's going on with your computer first thing that you might want to know is how's your memory situation going so you want to learn about the free command now free if you just run it by itself tells you what's going on with your memory but it does it in big numbers that are kind of huh they're just like what is that I think it's I think it's kilobytes or something like that so that kind of is hard to read so what I do is I use H on free and that gives you humanly readable output and it tells me that the memory in my machine I've got 31 gigabytes total well there's actually 32 but it rounds down we are using 1.4 gigabytes to run the system 21 gigabytes are free shared memory is 14 megabytes that's taking up a little space and our cache and buffers is 8.2 gigabytes the cache is stuff that has been read from block storage devices the system hangs onto that leaves it in memory and if it needs it again then it will run it from the cache instead of actually reading it again from the drive so if you have a slow spinning hard drive on your machine like you're on an old laptop with a 5400 rpm 2 and a half inch drive the first time you Loza load up your web browser be it Firefox or Google Chrome or whatever it takes forever to load you ever notice that that's because it has to read all that stuff off that drive but the you close the browser you come back to it later and you open it again and guess what now your web browser just opens right up like a shot the reason why is because it's reading it out of memory as long as there's enough memory on the computer to contain what's in the cache it will be read from the cache and not from the drive the cache memory doesn't take away from available system memory because if you need more memory stuff that's old and the cache gets dumped and then it's reused the memory management of the system is trying to figure out how to do the best with what you have also the free command shows you your swap space and whether it's being used on this machine we've got 32 gigabytes of RAM installed it's not going to be swapping a whole lot but like I said you do need a little bit of swap space for the kernel just in case it needs it so we're safe here this machine's going to be really stable as it runs so the free command is very useful the next one that I want to show you is disk free DF and once again we're going to use that H to make it humanly readable on this command so if I no typed in d FD instead of there you go now it shows us all of the block storage that's attached to the system and how much space is available in that block storage and it even goes so far as to show us things like snap packages and virtual file systems that are used by the kernel like temp FS there and you see how that works so this is actually very useful if you're wondering if your drives are getting full and you want to see what's going on and then finally the last one that I'm going to show you is kind of a silly one but it's really useful called uptime and what uptime will tell you is how long the computer spin-up it tells you how many people are logged in and it shows you a load average on the computer so the load average basically works out you got three numbers and it'll be 0.01 point something and so the first one is the last minute the second one's the last five minutes and the third one would be the last 15 minutes so this machine has pretty much been doing what it's been doing pretty steadily for the entire time that I have been doing this video we haven't been loading it down because really the only thing that it's doing is recording video and that's what's giving it a load at all now if you run this and you see that your system is giving you really high load averages like around 5 or 6 or something like that your system is working really hard and you might want to go figure out exactly why so those three little things they're very useful and what I did was as I wrote a script that would let me run all of that at once and I want to show you how I put that together so it's in bin and the name of the script is check Cistus actually for a server because I do have a server for easy Linux that I log into and maintain and I want to know how the system is doing as soon as I log in I want to know what's up so I can run this script right here and it will run these three commands so the first one is s the the free command which we looked at the second one is the DF command to find out what's going on with the drives all of this gobbledygook on the end right here basically filters out that output on the screen and it just gives me devices that's all it does and it's all of this right here that's what that does and then finally uptime when I created this script one of the things I made sure is that I put the exact path name the path for each application that I was going to run I did that on purpose because I want it to be very fast I don't want it 1/2 I don't want it to have to go check the path because that actually slows things down a little bit so I'm gonna leave this up on the screen while I'm talking you can pause it and you can copy this down this is one that I cannot share in the YouTube description simply because of the fact that it is got a lot of brackets in there and YouTube doesn't let you post brackets but if this is something that you want to actually try for yourself there it is so when I run that it clears my screen and it gives me all of that information in one fell swoop this is an example of useful system monitoring right here and there are so many other commands that you can use to get information I'm just gonna show you a couple I mean just a couple there are tons of these and pretty much any information that you want to figure out you could probably go online and search for how to find out at a command line bla and it will show up they'll give you a command that'll do it one command that we've already looked at is LS block that shows us all of the devices that are hooked to the system but we can also use LSP CI all of the storage devices hooked to the system but we can also use LSP CI to show us all of the devices on the PCI bus so this spits out a bunch of great information here here's another one that we can use this is LS CPU that just tells us about the CPU in this machine we've got two CPUs four cores each so it's 12 Xeon CPUs and it tells you all the information about the CPU in your system here's another one that's kind of useful that you'll run into when you're trying to get the IDS off of all of these devices you'll notice that in the FS tab file it wants to use Universal IDs device IDs to mount the drives well you have to figure out what those are so let's let's get a list of those so you have to do this as the root user will do BLK ID and now we have the block IDs for all of the partitions on this machine right now we even have the UUID I'm confusing you now yeah oh no it's block ID UUID that's exactly what we're doing we have the UU IDs for the partitions that are mounted to the system and that's how that works very useful command so there's more I mean we could go through a ton more of commands like this that give you raw information but it really becomes useful when you start using tools that bring all of this stuff together so an old tool that's been around on Linux for a really long time that brings all this stuff together that I've just showed you is top the top command not only shows us stuff that's going on with the system and how the memory is being used it also shows us the processes that are running on the system these are programs or services that are running it shows you who owns those programs how much CPU they're taking up and very importantly it gives you a PID which is a process identification number you can get the process IDs for what you're running in your own environment with a very simple command and I'll show you that one right now let's just run PS and you'll notice that it only shows us a couple of things because we're not running much but if I should do this if I should do G edit right and then I keyboard went a little nuts there for a second so put the ampersand on the end put that in the background and we opened up G edit and I'm gonna go back to my terminal that's gonna be running in the background and let's open up something else well I don't know we'll open up Nome disks we looked at that earlier right let that open up and we will go to the terminal leave that in the background oh I forgot to put the ampersand hang on folks let's do that one more time put on the ampersand there you go and now if I run that same program that PS program PS command it shows us that oh there's a Freudian slip for you I said PS my mind thought BS and then my hands typed it that's a good one so there you go now you see that we have other stuff running in the background so that's running services or in programs that we have started ourselves and we can get rid of those programs by killing them and using the numbers there that have the PIDs we can also kill them pretty easy but just doing kill all so if I want to get rid of gee edit and then run PS again you'll see that is now gone so you might be familiar with doing something like this kill nine which tells it to hang up and you and then you type in the PID number there and it gets rid of it right we're not gonna do that we don't need to we can just do kill all a lot of programs these days they open up more than one process while they're running and so therefore we can just use kill all to get rid of them if we know we're running them we can use PSA to see all of the processes that are running on the computer whether we have access to them or not and it outputs a lot of information we can use top we already looked at that now what I like to use at a command line this is a program that I always install it doesn't necessarily come automatically with your Linux system but it's one that I use a lot it's called H top and it's in the repositories for just about every distribution somewhere so like on a boon to or Debian just put in sudo apt install H top and you'll get it and this really puts everything together up top it shows us what our CPUs are doing they're capturing video right now which is why they're working so hard and then we get all kinds of information we get our load average right there we get the uptime this machine's been up for three days how many tasks are we running 141 two are running right now it shows us what's going on with the memory the same deal doesn't show us the buffers and all that stuff shows us what's going on with swap there and one of the beautiful things about this program is that it responds to your mouse so if I want to filter that out and I just want to look with anything with simple in it look there's all the threads that are open right now with simple screen recorder and then if I want to kill a process I can do that with a mouse click or by using the function keys H top is a program definitely worth getting and playing with extremely useful I've got it running on every Linux machine that I have I do have a video on the channel where I go through everything about H tops so you can look at that as well and finally before we wrap things up we're talking about system monitoring and processes we just really touched on all that stuff there are books written on that subject so you can go out and find out more but of course if running a desktop then you probably will use a graphic system monitor and there's absolutely nothing wrong with that most desktops come with a system monitor we're using gnome so we get the excellent gnome system monitor and it shows us all the same information it shows us what processes are running on the system and then you can go through here and just click on things and then you can kill them you can do whatever you want with them this shows the CPU usage memory and then finally you can see how your drives are doing as well so there you go gang we've covered a lot of ground in this video thank you for hanging out with me hey this is the longest one in the series so far but I wanted to get that out of the way because I don't know when the next time I'm gonna get back to this series is gonna be so if you watch video one two and three just break them up take some time watch them learn them you're gonna have a whole lot of information under your belt suggestions feedback always welcome and you can also join the discussion and easy talk you can check out easy Linux on Facebook if you're a Facebook user and if you do like the channel please on Facebook that certainly does help and of course there's easy Linux comm where all of this stuff comes together thanks again for watching this was a really fun video to do I hope you got something out of it we'll talk again soon
Info
Channel: Joe Collins
Views: 12,305
Rating: undefined out of 5
Keywords: Linux, OS, Computer, Terminal, Compoter, Software, Desktop, Laptop, Server
Id: 948AadKDg5E
Channel Id: undefined
Length: 58min 22sec (3502 seconds)
Published: Tue Sep 17 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.