Download Audio File, choose format OGG MP3
 Closing Music:DJFredse - Ciber Lesson

What Do I Have?

Deepgeek

Abstract: This is a script for a podcast. How can you find out what hardware Linux understands your computer to consist of? Commands that reveal Linuxes understanding of your computers capabilities can be used to assist you in troubleshooting, as well as setting up other operating systems on your computer that may need you to seek out drivers for them.

1  Introduction

Today I thought we would look at commands that will have Linux tell us what our computer is made out of, what it can do. Why would we want to do this.

This information can come in handy for troubleshooting. Let’s say your audio isn’t working on your computer. You may need to know exactly what kind of sound device your motherboard has to throw some arcane setting that may allow ALSA (the Advanced Linux Sound Architecture) to take off and work well.

Another application can be supporting a Windows installation. Installing Windows often requires chasing down device drivers, when I support a Windows box (which isn’t often,) I always install a command line Linux partition just so I can ask Linux what the computer is made of.

Depending on your distribution, a command may be already installed or you may need to install a package to get it on your system. For instance, I use Debian, and I once talked to a group about a calender CLI app called “cal.” I found out that the Ubuntu crowd did not have it pre-installed, and had to install a package called “bsdmainutils” to get some BSD-style utilities added to their system. Likewise, Debian does not automatically have hdparm or lshw, your have to give the system an apt-get install hdparm lshw to get them. When in doubt, query your package manager (whatever that may be) and do an install, not every distribution comes with every CLI app installed.

And, lastly, I will be trying not to belabor any command, as I think it will make for “bad radio.” So, the idea is to give you an idea of what is out there, so if you find yourself interested you can learn more about it on your own. And please note that most these commands are global in scope, so you will have to be root user to use them.

2  HDPARM

HDPARM is a utility for querying and setting disk drive parameters. Not only can you get the disk drive to “spill it’s guts” over what it can do, and what it is set up to do, but you can change and tweak disk drive parameters to your hearts content. It also includes some rudimentary performance tests. The documentation is very good, and even features in all-caps warnings such as “VERY DANGEROUS” and “USE AT YOUR OWN RISK.”

That sounds provocative, but it really looks like one of those tools where you can shoot yourself in the foot if your not too careful.

I find that the most useful features are the capital-i, capital-s, and capital-c functions. So if you give the command “hdparm -I /dev/sda” you will get an exhaustive query of what the drive is and what features are enabled. Issuing a “hdparm -S 242” will set the spin down on the disk drive to one hour. Lastly, “hdparm -C /dev/sda” will tell you if the drive is spun down or not.

3  lsusb

“lsusb” lists devices on the usb interface. On Debian, this one is part of the base install. This command will be the one you turn to when you buy a new usb device, and want to see if the system knows it’s there when you plug it in. You would use the command “lsusb.” When I use lsusb, I get a list with my usb keyboard and mouse, and the Linux Foundation drivers for USB version 1 and 2.

“lsusb” oft times recognizes devices for which the kernel has no drivers. So, for instance, recently I tried some Sony USB-based hardware, and I used lsusb to see what it was. Sure enough, it was plugged in. But I couldn’t use it. A few minutes of searching the Internet, and I saw that the device needed a special windows only driver. Instead of futzing around at this point, I ran back to the store for a return and I saved myself all kinds of heartache.

4  lspci

Let’s talk about lsusb’s cousin, lspci. It lists devices on your computer pci bus. This command will give you some very verbose output, listing all kinds of parts that are, in fact, internal to your computer’s motherboard.

What use is this, you may ask. I learned this command troubleshooting video and audio a few computers ago. This command will show you, for example, what series of nvidia video hardware you may have, or which sound device your motherboard sports. Of course, it also shows you what any card you have plugged into your computer is.

Now that last one is a trick. Let’s say you go down to a local computer store called Joe’s, and he sells you a “Joe’s Video Card,” really cheap. Since this command queries a plugged in card, it will tell you what the chips on the card say they are. So, in this made-up example, your “Joe’s Video Card” may tell lspci that it is made up of chips of the nvidia GE 7300 series of video cards. Now you know two things, who “Joe’s contractor” is for video cards, as well as what driver you installation of X window system you need.

5  lshw

This one, like hdparm, probably needs the old “apt-get install” routine. This one comes in a GUI form too, but at least on Debian, that would be a separate install (since Debian does not assume you are a desktop machine.)

“lshw” is the king of verbosity. On my system lsusb gives about 5 lines of output, and lspci gives about 20. Lshw offers up 500 lines of output! So, be prepared to use grep. So you can, for instance, issue a “lshw | grep /dev” and get list of all the active disk drives on your computer. But I also recommend you give a complete output of this command just to know all about your computer. For instance, the section on your CPU will tell you what your CPU is, what model of that CPU you have, what it’s different caches are. Hum a few bars of “Getting To Know You” while you read it over.

6  Disks

Let’s take a look at a few ways of knowing what your computer thinks the disks are. I find this important, because I am forever using the “autodetect partition filesystem” option of the mount command. So I will, for instance, purchase a USB drive, and mount it, not knowing what kind of disk it is on the inside. Heres a couple of things you can do after mounting a drive to see what you got.

The diskfree command is “df,” so I would probably issue “df -h” first. This command tells you how much disk space you have free, and the dash-h option gives you those sizes in human terms, like “50G” for fifty gigabytes. It also tells you where each mount is for each partition on a disk, which can be useful.

To go back to the USB drive example, how do you find out what your disk is formatted is. To get this information, I would recommend you give the command “cat /proc/mounts”. Printing this pseudo-file that the kernel maintains in the /proc directory will tell you what file system a disk is mounted as.

7  Filesystems

What filesystems does my kernel support? Here, we turn to the the /proc directory (a good place to poke around on your own, if you like.) issuing the command “cat /proc/filesystems” will show you all the filesystems you are set up to support.

8  Modules

I always think of modules when I think of filesystems, because I have installed some special extra filesystems. Let me give a quickie on how this works.

One of the extra files systems my system supports is squashfs. Now, on Debian, this is not automatically in the kernel, you have to load a module. In order to do this, I did an “apt-cache search squash” and found a package “squashfs-module” (with some extra stuff in the name for different kernels.) I install the right modules package for my kernel. To give detail, I find out what kernel I have by issuing a “uname -a” and then I install the modules package for that. Then, to finish installing the add-on filesystem, I also install the “squashfs-tools” package (so I can create that file system,” and to top it off I add the name of the module to the end of the /etc/modules file.

To check things out, I do a modprobe squashfs to add the filesystem right now without rebooting, and then I check the modules Linux knows it has.

I do this by issuing an “lsmod | grep squash” and sure enough, Linux lists this module, check /proc/filesystems will tell me this also.

You can also find out some other interesting things. For instance, my motherboard uses the nvidia chipset, so a “lsmod | grep nv” shows me the modules Linux has for nvidia chips. Likewise, “lsmod | grep snd” shows me all the sound modules my system is using.

9  Conclusion

To wrap it up, you can see that the command line can be a real tool to find out what your computer thinks it is on the inside. If there are any other commands you can think of for such troubleshooting, I hope you will drop me an email.