How do I get hardware information on Linux/Unix?

15,704

Solution 1

If you need a simple answer, use:

  • cat /proc/cpuinfo
  • cat /proc/meminfo
  • lspci
  • lsusb

and harvest any info you need from the output of these commands. (Note: the cut command may be your friend here if you are writing a shell script.)

Should you need more detail, add a -v switch to get verbose output from the lspci and lsusb commands.

If what you are looking for is a more feature-complete API, then use HAL, though that may be an overkill for what you are trying to build.

Solution 2

If you are looking for a tool that show System Information, the GUI tool like HardInfo would useful for you.

In Ubuntu, you can install HardInfo like this...

sudo apt-get install hardinfo

Cheers

Solution 3

There is a bash command lshw - list hardware

Solution 4

I would use hal, the hardware abstraction layer. It includes both some GUI commands, some tty commands (which can be used from shell programs), and library bindings for c and multiple other languages.

HAL is not really a standard part of "linux", but I think it is used by most modern distros.

Solution 5

Try sudo lshw. It's the easiest.

Share:
15,704
Unicorn
Author by

Unicorn

Updated on June 04, 2022

Comments

  • Unicorn
    Unicorn almost 2 years

    How I can get hardware information from a Linux / Unix machine. Is there a set of APIs?

    I am trying to get information like:

    • OS name.
    • OS version.
    • available network adapters.
    • information on network adapters.
    • all the installed software.

    I am looking for an application which collects this information and show it in a nice format. I have used something similar with the "system_profile" command line tool for Mac OS X. I was wondering if something similar is available for Linux as well.

  • Suppressingfire
    Suppressingfire over 14 years
    In some circumstances, lshw might not be available, but dmidecode, which provides similar information, often is (I'm thinking on VMware ESX hypervisors).
  • Suppressingfire
    Suppressingfire over 14 years
    @Unicorn, can you be more specific about the hardware information you want to extract?
  • Ferenc Deak
    Ferenc Deak over 14 years
    Or write some script in a nice scripting language to fetch and format the data the way you want. Don't forget to add ifconfig for network adapter infos.