Open Source

Get Linux and FreeBSD hardware info with guide to commands

This guide to select commands for getting hardware information will help clear up some of the confusion that might arise when switching between FreeBSD and Linux-based systems.

Switching between open source OSs can sometimes be confusing, since they may have different ways of doing things. A common task that may confuse some users when switching systems is getting hardware information. In the case of Linux-based OSs and FreeBSD, the following cheat sheet for figuring out how to do the same things on two different systems can ease some of the pain.

CPU and memory information

Because Linux-based systems use the proc device filesystem to provide access to information about hardware devices in the system, getting specific information about the hardware sometimes involves finding it in files using the grep command. The same information is normally accessed on FreeBSD via the sysctl command.

To get information about your CPU model . . .

  • Linux:
    grep model /proc/cpuinfo
    
  • FreeBSD:
    sysctl hw.model
    

To get information about total system memory . . .

  • Linux:
    grep MemTotal /proc/meminfo
    
  • FreeBSD:
    sysctl hw.realmem
    

Device listings

Information about many other devices might be needed as well. For these, each system has tools designed to provide listings of devices connected to various system buses.

To get information about PCI devices . . .

  • Linux:
    lspci -v
    
  • FreeBSD:
    pciconf -lv
    

To get information about USB devices . . .

  • Linux:
    lsusb -v
    
  • FreeBSD:
    usbconfig
    

To get other connected device information . . .

  • Linux:
    dmidecode
    

    This command shows DMI/SMBIOS hardware information.

    lshal
    
    This command shows all devices managed by the HAL subsystem.
  • FreeBSD:
    atacontrol list
    

    This command shows all ATA devices.

    camcontrol devlist -v
    

Notes

Some of the above commands may work from a normal, unprivileged user account. Others may be restricted to root access.

On both of these OS types, a lot more information can be had by means similar to those described above. For instance, the /proc/cpuinfo and /proc/meminfo files contain a lot more information than just the CPU model and total memory. There is a sysctl command on Linux-based systems as well as on FreeBSD and other BSD Unix systems, but it is not as broadly useful as on FreeBSD, nor does it offer as comprehensive coverage of the system, because Linux-based systems default to other means of accessing and configuring system configuration values (such as the proc filesystem). On either system type, a picture of sysctl capabilities can be seen by viewing the utility's manpage.

If you are feeling curious and have some time to spend exploring, sysctl -a outputs all information sysctl has to provide.

About

Chad Perrin is an IT consultant, developer, and freelance professional writer. He holds both Microsoft and CompTIA certifications and is a graduate of two IT industry trade schools.

Editor's Picks