4

UPD: Changed question title from manage devices to discover information about devices

One of the frequent thing I do is look up info about devices on my systems. And I am constantly find myself confused about various different commands on Linux to query available disks, network adapters, graphics cards etc.

For example, if I need to query all disk drives available, I do:

ls -la /dev/disk/by-id

If I need to query all network cards available, I do:

ls -la /sys/class/net

Is there any single point to query all device ids by type?

Maybe there was initiative to unify handling of devices info and make it discoverable/accessible, but it failed?

History of the question in order of appearance:

  1. /dev/disk/ lists disks, why /dev/net/ doesn't list network interfaces?
  2. Why are network interfaces not in /dev like other devices?
anatoly techtonik
  • 2,514
  • 4
  • 24
  • 37
  • there is now on most linux distro the command `lspci` `lsusb` and so on that allow a nice listing. But I don't thing there anything working everywhere. – Kiwy Dec 18 '13 at 09:12
  • 3
    Your main issue is also one of mine: network interfaces not having entries in `/dev`, thus being among the few devices that break the Unix file paradigm. It messes with my Chi, man. (and my OCD) – Alexios Dec 18 '13 at 10:38

2 Answers2

3

I think you are looking for hwinfo command. This command helps you to query disk, network and other hardware information

SHW
  • 14,454
  • 14
  • 63
  • 101
  • I was actually looking for a location on a filesystem where I can query all this info with `ls -la`. I don't dare running `hwinfo` inside my server processes. – anatoly techtonik Dec 18 '13 at 14:27
  • 1
    @techtonik Mind you, that not everything has a file representation that can be queried by opening and reading. –  Dec 18 '13 at 16:07
  • @HermanTorjussen, for instance? – anatoly techtonik Dec 18 '13 at 19:23
  • @techtonik For instance information about the motherboard. –  Dec 18 '13 at 19:44
  • @HermanTorjussen, why there is a problem to provide `/dev/motherboard/model` and other user level fields? – anatoly techtonik Dec 19 '13 at 03:08
  • @techtonik I never said it was problematic, I just said it isn't necessarily so. You question is a bit vague: are you looking for a specific solution to some specific query, or are you asking why there isn't a general solution to managing devices? Please clarify in your question for future readers. –  Dec 19 '13 at 09:38
  • let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/12068/discussion-between-herman-torjussen-and-techtonik) –  Dec 19 '13 at 10:17
3

There is no single standard or tool to query hardware devices on Linux systems in general. Depending on your host's architecture, and which of its components you must query, and how much detail you need about it, you may need one or more tools specific to that component. However some commands/tools are in wider use and have greater mindshare than others. Following are some--that may or may not be available for your particular host--but are nonetheless Generally Regarded As Useful and widely available from major package managers (though I only link to Debian below):

all-purpose query tools:

tools for specific subsystems:

  • dmidecode - processor, memory and motherboard details from BIOS
  • lscpu - processor details from /proc/cpuinfo
  • lspci - PCI devices, typically graphics cards, audio cards, network cards
  • lsusb - USB devices in general
  • ls -l /dev/disk/by-{id,label}/ - block devices and their block device files
  • ls -l /sys/class/net/ - network devices and their network interfaces
  • udevinfo - block devices, if using udev

I encourage people to expand this list if some essential tool is missing.

TomRoche
  • 1,275
  • 3
  • 15
  • 29