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.

14 comments
Orodreth
Orodreth

Linux hardware info should start by actually listing and printing the contents of files found in /proc. For instance the Linux commands more /proc/cpuinfo lists all information about the processor in the system. the Linux command free lists system total, used, free, shared, buffered, cached, and swap file memory. the Linux command more /proc/partitions lists the partitioning of the system disks more /proc/mount lists a little more information than the usual mount command.

Neon Samurai
Neon Samurai

My understanding is that the BSDs differ more at the kernel level than the userland. Would those commands above be common across most of the BSDs?

kashishraj
kashishraj

a lot more information can be had by means similar to those described above. debtadviceni.com

Sterling chip Camden
Sterling chip Camden

... on FreeBSD, at least, is that it is so comprehensive. The command line utility pipes well, and it has a nice C interface for writing your own utilities.

apotheon
apotheon

Yes. I confined my comments to FreeBSD in particular because I did not have a NetBSD or OpenBSD system handy to test commands. I try to make sure I test anything I include as a code or command example in my articles.

treibs
treibs

The link goes to Debt Advice of Northern Ireland, which does not seem to have anything to do with the current subject. Is there a typo in the link?

Neon Samurai
Neon Samurai

It really only caused me question because "Linux" was referred to in the general along side only one of the BSDs. Having both the Linux and BSD examples provides a nice bridging article for us folks who haven't got both feet wet with BSD yet though. This one went strait into the PDF library.

Neon Samurai
Neon Samurai

A pretty graphic installer may be nice to have but it shouldn't be a daily need. You install the OS, it runs. Also, how is a graphic installer preferable to a clean text display given the need for visually impaired use? Debian provides both GUI and text based installer interfaces and the text is still preferable; no reason for the GUI layer that presents nothing different from the text version. Text to speach sure prefers a rational text based interface. I could see being able to magnify parts of a graphic display but I don't know of any installer which provides an onscreen magnifying glass. Also, why are you basing opinion of the entire OS on it's installer? Do install wizards affect how any other program runs once installed? Skype doesn't much care how it was installed provided all it's files are on the drive when needed. The fact that Skype has a GUI installer doesn't change the quality or functionality of it's sending voice and video over IP networks. Admittedly, I don't know your specific situation. I'm only drawing on my own experiences with vision problems.

apotheon
apotheon

> True PC bsd has just released a graphical installer on the lastest release PC-BSD has had a graphical installer for quite a while now. > more advanced Open source alternatives such as Ubantu,Fedora,etc What is your definition of "advanced"? In many ways, FreeBSD is more advanced than either of those.

The Management consultant
The Management consultant

True PC bsd has just released a graphical installer on the lastest release...which helps but to quote reviews it still two releases behind what it should be! Clearly for partially sighted people like me it cannot concequer the desktop at the moment if UI is not there.Clearly I would like to be a fan but at the present position in the development cycle its not competing with other more advanced Open source alternatives such as Ubantu,Fedora,etc

apotheon
apotheon

FreeBSD is widely deployed and heavily used. [China chose it as the basis for its secure OS.](http://blogs.techrepublic.com.com/security/?p=1682) It has some of the highest uptime numbers measured on the Internet. It's running on this laptop right now. The installer works great for many users. In many ways, it is better than the installers for OSes like MS Windows, Apple MacOS X, and Canonical Ubuntu Linux. It maybe going nowhere for you, but you are not everybody. You are one person. edit: Maybe you should give PC-BSD a try. It's based on FreeBSD, but designed more for non-technical users such as MS Windows server admins, and has a "friendlier" (but less flexible) installer.

The Management consultant
The Management consultant

unfortunately I tried to install FreeBSD on my PC last week...without the development of a decent installer this os is going nowhere especially for partially sighted people..will stick to easier OS types like openindiana who actually have a decent install programe!!

apotheon
apotheon

It's understandable that the generalized use of the term "Linux" would make you sit up and take notice in contrast with the specific mention of "FreeBSD". These commands tend to rely on kernel design, however, and while Linux distributions by definition use the Linux kernel, each major BSD Unix system maintains a separate kernel development project. While I'm pretty sure the commands I cited would work on NetBSD, OpenBSD, and Dragonfly BSD as well, I have not confirmed it, and the fact their kernels are developed separately prompts me to proceed with care.

Editor's Picks