[Music] [Music] hello and welcome back to learn Linux TV in today's episode of the Linux crash course series what we're going to do is cover a handful of commands now normally I try to cover just one command per video in the series but each of the commands that I'm going to show you in today's video each share a common theme these commands help you inspect hardware for example we'll look at ways to view info regarding USB devices your PCI bus and so on so if you've ever had anyone ask you about your network card or what kind of CPU you have and you didn't know how to answer their question then this is especially the video for you so the commands that I'm going to show you in today's video are going to be especially helpful and speaking of helpful I need to thank the sponsor for today's video acam my connect to Cloud if you're looking for a cloud provider that's affordable flexible and reliable then look no further than aami connected cloud with aami's Cloud platform you can spit up Linux servers quickly and the platform contains all the features you'll need to deploy full featured Solutions and using the marketplace you could easily deploy applications such as nexcloud Rocket chat Mastadon WordPress py hole Plex Jenkins and many more in fact there's over 100 applications available in the marketplace if you want to set up a custom Linux instance you could do that too all the popular Linux distributions are available on the platform including but not limited to Debian Cento Fedora Ubuntu and many others in fact even Arch Linux is available so check out aami connected cloud with the URL that you see on the screen right now which will do two things first it'll help support this channel which I'll really appreciate and it'll also get you $100 in starter credit to check out the platform thank you so much to aami for sponsoring today's video I really appreciate it with all of that out of the way let's dive into Hardware commands on Linux now there's one thing that I want to get out of the way before we get too far into the video and that is to dispel the myth that you need the terminal or the command line for everything in Linux yes we are going to look at command line commands in this video but I wanted to point out that none of these commands are required for you to find out information about your hardware for everything you could do on the command line in Linux there's also a guey equivalent as well for an example of this on a nuunu desktop as well as a bunch of other distributions you could go to the settings app and then click on about and right there you'll get some information regarding your Hardware other graphical utilities exist to do this as well but we are going to look at the command line method in this video and the reason for that is because you might not always have a graphical user interface for example most Linux servers have no graphical user interface at all so if I teach you the command line equivalents of everything then you could use that on any Linux distribution whether it's a desktop distribution or a server distribution and thankfully these commands are not difficult to learn and to make it even easier what I'll do is go over the basic usage of each of these commands because the basic usage is all you'll need in order to inspect Hardware that's inside your computer or server and the first of the commands that I'll go over in this video is the lsusb command and as you can see this command gives us a list of USB devices just like the name suggests so there's a lot of information right here that could be useful to you for example if you have a USB device that you want to use with your Linux installation and let's just say it's not working correctly what you could do is find the output of that USB device right here from this command copy the entire line that pertains to that device and then paste it into Google along with the word Ubuntu or Linux or something like that and you'll most likely find exactly how to get that piece of Hardware working in fact for almost the entirety of my Linux career this is exactly how I do it but another thing that you might want to do is find out if your USB device is even detected in the first place and this is a great command to use for that in order to make it even more fun what I'll do is combine the lsusb command with the watch command now I have an entire video in this series that covers the watch command so I won't give you a ton of detail about that command in this video if you want to learn more about the watch command you could watch that video but a basic summary of what it does is by default it'll run the same command every 2 seconds and to make this example even better I added the- D op option and what that does is highlight differences so it'll be very obvious when I plug in a USB flash drive where the difference is you'll see that right away anyway what I'll do is plug in a flash drive right now and pay attention to the output and what you can see here is that the third line down is the flash drive that I've just inserted now the DD option like I mentioned will show you all the differences and it showed more than just that one line because that one line caused everything below it to shift down but the point is here that we see the flash drive right here with the lsusb command even without the- D option it's still going to do the same thing it lists USB devices like you can see right here but by using the watch command I can immediately see when a device is on the bus and the third line down the Kingston flash drive that I've just plugged in well it's available it's on the bus and I can now use it if I remove it then the line goes away anyway the lsusb command is a great way to find out which USB devices have been detected by your system and you've just seen what happens when I plug in a flash drive it shows it immediately when I use the watch command combined with lsusb and just like with most commands on the Linux command line there's a few options that you could use with the lsusb command as well but those options have more to do with printing information from a specific bus most of the time unless you writing device rules of your own it won't be common for you to need something like that but there is one option that's definitely really useful that I'll give you right now and that is the- T option so if I run lsusb and then- T let's see what happens and I really love this the- T option gives you information on your USB devices just like before but it displays the information in a tree View and in my opinion this makes it easier to understand how everything is interconnected next let's move on to the ls PCI command and just like the lsusb command I think it has a very clever and easy to understand name we know LS from the ls command that's how we list storage on the Linux command line so we could already guess that LS means to list something and when it comes to PCI I think that's fairly self-explanatory that's your PCI bus and as you can see here we get all kinds of information regarding devices on our PCI bus from the output here you're actually going to see quite a bit of detail regarding the computer that I use for recording footage on this channel you can see for example that I have an Nvidia GPU you see that right in the output and as I scroll up we have even more information so as you can see if you wanted information about devices on your PCI bus then the LSP PCI command is a great command to use to get that information as for some of the reasons why you might need a command like this again Linux compatibility is a very common reason for example if you want to understand whether or not a particular device works with Linux you could copy a line from the output here paste it into Google with the Search terms Ubuntu Linux or whatever distribution you're using and you'll probably find out information when it comes to how to get that device working in the case of Nvidia you'll probably find information regarding installing the proprietary Nvidia driver that's often required when it comes to Invidia gpus now most of the time almost everything on your computer will be supported out of the box but it's not uncommon to have that one device that needs a little bit of convincing to get to function properly but it's not all that common to need to convince a device to work properly anyway if you wanted to find out information regarding devices on your PCI bug then the lspci command is a good command to use for that purpose sorry to interrupt myself but I just wanted to let you know that I really enjoy making this content for you guys I have a ton of fun if you enjoy the content that I produce then please consider supporting learn Linux TV the thing is producing content like this isn't cheap so by giving back to the channel you can help me make even more content for you guys and to find out more about how you can support learn Linux TV what you could do is go to support. linux. TV and there you'll find some of the ways that you can help support the channel anyway let's get back to the video but what if that's not enough information well we have another command that'll list Hardware on your computer and that command is LSW this will give you quite a bit of information regarding your Hardware possibly more than you needed but anything you might want to know it'll definitely have that information now at the bottom it's telling me that information might be incomplete or inaccurate because I did not run this command with sudu so in order to heed that what I'll do is type sudu and then LS well actually no I'll type sudu exclamation mark exclamation mark because what that does is it repeats the command that I've used most recently which is lshw but it'll prefix that command to with Pudu so I don't have to type the entire thing sure lshw would have been only two more characters but I wanted an excuse to give you this tip and I thought that was a good excuse to do so so well if you didn't know that now you do and we no longer get that warning at the bottom of the screen but anyway if I scroll up here you're going to see even more information about the computer that I use to record footage on this channel probably more information than you ever wanted to know I keep scrolling and scrolling and scrolling there's just so much information here but I'm pretty confident that anything you might want to know about your Hardware can be discovered using this command it's very powerful and again the command was lshw and I used Pudu in front of it because that's well required if you want to see all the information that it can possibly show you but there is one option with this command that I definitely want to show off and this is really really cool so what I'll do is add the dhtml option now most commands that are longer than one character on the Linux command line will need two dashes but this is a bit of an exception here because the dash HTML command just has a single Dash so that's not a typo that's absolutely expected anyway when I press enter we see HTML well I guess that makes sense considering that I use the dhtml option but what exactly are we going to do with this output I mean it's not like we have a web browser in our terminal well there's actually a few web browsers that you could use within your terminal but I'll save those for another video but what we could do to make this even easier is we could simply redirect the output into a file so what I'll do is redirect it into a file called hinfo HTML and well it seems to have worked and in fact we have the file right there so what I'm going to do right now is open a web browser and I'll open that file let's see what it looks like so in the case of Firefox I could press alt and that reveals the file menu and I'll just go to file and then I'll click open file and here's the file right here let's open it up and see what it looks like now how cool is this from the command line we were able to print HTML output from the lshw command and this information right here might be valuable if you're trouble shhoting something or maybe you're working with someone who troubleshooting something if you want to compare your system with theirs or perhaps attach this to a bug report and if you did that then this report would have all the information that a developer might need to help understand why something might not be working well on your computer now they'll probably have more information than they need but I think everything they might need is covered here and as you can see it's a very useful command now there's another option that I would like to give you guys and this next option will shorten the output so if you felt like the output was Overkill there is actually a way to shorten the output and you do that by adding the option- short like you see right here now I really like this option I really like how everything is presented with this option so if what you're looking for is within the output here then this might even be the best option to go with either way I've shown you a few different versions of output from this command and you could choose whatever fits your use case now that's all well and good but what if you wanted information just about your CPU well for that we have LS CPU and just like the name would suggest this command gives you a lot of information regarding your CPU so if you wanted to find out more about your CPU then you could use this command and from the output here you can see for example that my footage PC contains an AMD ryzen 9 3950x 16 core CPU it's definitely a powerful CPU I really love it it's probably more powerful than I need for a computer that exists simply to capture footage but at least I'm not waiting for the computer to complete anything it's definitely been a great machine for this purpose but anyway as you've just seen the ls CPU command gives you information well about your CPU now all the commands that I've used so far have centered around USB PCI devices and your CPU but what about storage well for that we have lsblk now depending on how long you've been working with Linux or servers in general for that matter you may or may not know about the term block storage and the definition of that is pretty simple and I'm going to oversimplify it block storage devices are well hard drives if you think about your computer's hard drive or SSD then those are block storage devices so what the lsblk command enables us to do is list block storage devices so I'll press enter and there you go now we can ignore everything that has the word snap in it because that's not why we're here that's not what we're looking for when it comes to snapd something that runs in the background that enables you to run snap packages it creates quite a few loop back devices as you can see but we're going to ignore those and we're going to focus on what's at the bottom where we have nvme0 And1 and to the right of that it has a type of dis so we could tell right here that nvme0 N1 is the name of the dis inside this computer below that we have the same name three more times but at the end of the name we have P1 P2 and P3 and each one of those refers to a different partition so we have NVM 0 N1 partition 1 partition 2 partition 3 you get the idea so your output might look a lot different than this you might have something like SDA that's very common you might have something like vda depending on what kind of dis you have in your computer or server its naming convention might be different but what you'll see across the board is you'll see a device name and the type will be disk and then underneath that you'll have your partitions and you'll know their partitions because the type is part as you can see to the right of each of those and lsblk is yet another command that I like to use in combination with watch but why well think of it this way let's say you wanted to wipe a storage volume and you wanted to make sure that you're wiping the correct one it' be very embarrassing if you overwritten the entire operating system of your computer server when all you wanted to do was format and create a partition on an external storage device so what you could do here is you could run lsblk with watch which will show everything that's currently connected and I haven't even plugged in a USB flash drive yet which is what I'm about to do and when I do that you'll see a new device that'll be added to this list right here and by comparing the output before and after I plug in a storage device a flash drive external hard drive whatever it is then we'll absolutely know which one of the items on this list pertains to that device which will help make sure that we target the correct one so I'll plug in a flash drive in three 2 1 and just like that device SDA appeared that was not there before but the point is I know exactly which one of these devices pertains to the device that I want to Target because SDA was not there before it's there now so that narrows it down immediately and then when I remove it of course it goes away and those are the commands that I'm going to go over in this video now sure there's many other commands that we could use so yeah I know there's going to be at least a few people in the comments letting me know about some of the commands that I didn't cover but I can't cover them all in one video I didn't want to overload you guys and the commands that I've given you should be perfect for basic usage and anytime you want to well inspect your Hardware I hope you guys enjoyed this video if you did please click that like button that helps YouTube understand that you enjoyed this content and who knows maybe more people will see this content as a result of you clicking the like button either way thanks so much for checking out this video I really appreciate it and I'll see you in the next [Music] video [Music]