Unicorn
Unicorn

Reputation: 2422

How do I get hardware information on Linux/Unix?

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

I am trying to get information like:

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.

Upvotes: 8

Views: 19181

Answers (7)

Dominik
Dominik

Reputation: 111

You can use inxi which provide all hardware information including cpu temperature and so on.

Install on Red Hat based OS sudo dnf install inixi

Install on Debian based OS apt-get install inxi

Upvotes: 0

oli
oli

Reputation: 11

Try sudo lshw. It's the easiest.

Upvotes: 1

Jai Prabhu
Jai Prabhu

Reputation: 207

Since you mentioned API, try the exec family of commands for C. You can use them to execute these binaries that other people have mentioned. To create a robust/flexible solution you will probably also have to leverage the Unix fork() commands. You will also have to develop a mechanism for capturing the output spewed by these utilities. Look into Unix pipes for that.

Upvotes: 0

Ei Maung
Ei Maung

Reputation: 7153

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

Upvotes: 8

AttishOculus
AttishOculus

Reputation: 1489

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.

Upvotes: 18

Rasmus Kaj
Rasmus Kaj

Reputation: 4360

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.

Upvotes: 2

Mojo Risin
Mojo Risin

Reputation: 8142

There is a bash command lshw - list hardware

Upvotes: 7

Related Questions