使用lshw命令获取Linux硬件信息
Lshw is a nifty small command line utility that generates detailed reports about various hardware components on the system. (lshw命令通过读取/proc目录下的对应文件来工作)
Lshw is capable of reporting memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, bus speed etc.
Install lshw
Ubuntu, Debian and Fedora users can get it from default repositories. On CentOS lshw can be installed from Epel repo.
# ubuntu, debian $ sudo apt-get install lshw # fedora, centos (epel) $ sudo yum install lshw
Using lshw
The lshw command needs to run with super privileges to be able to detect and report the maximum amount of information. So run as root, or use sudo.
Lshw assorts hardware components into groups called “class”. Processor, memory, display, network, storage are all different classes.
1. Display full information
Running lshw without any options would generate full information report about all detected hardware. It would generate a big output with quite a lot of technical details
$ sudo lshw enlightened description: Desktop Computer product: () width: 64 bits capabilities: smbios-2.4 dmi-2.4 vsyscall32 configuration: boot=normal chassis=desktop uuid=949AC704-8C43-11DE-9395-000EA68F7260 *-core description: Motherboard product: DG35EC vendor: Intel Corporation physical id: 0 version: AAE29266-210 serial: BTEC934000EK slot: Base Board Chassis Location *-cpu description: CPU product: Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz vendor: Intel Corp. physical id: 0 bus info: cpu@0 version: Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz slot: LGA 775 size: 2664MHz capacity: 4GHz width: 64 bits clock: 333MHz capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx x86-64 constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority cpufreq ...TRIMMED
2. Display information in short
With the “-short” the lshw command would generate a brief information report about the hardware devices that would quickly give an idea about the hardware profile of the system.
$ sudo lshw -short H/W path Device Class Description =================================================== system () /0 bus DG35EC /0/0 processor Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz /0/0/1 memory 2MiB L2 cache /0/0/3 memory 32KiB L1 cache /0/2 memory 32KiB L1 cache /0/4 memory 64KiB BIOS /0/14 memory 8GiB System Memory /0/14/0 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/1 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/2 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/3 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/100 bridge 82G35 Express DRAM Controller /0/100/2 display 82G35 Express Integrated Graphics Controller /0/100/2.1 display 82G35 Express Integrated Graphics Controller /0/100/19 eth0 network 82566DC Gigabit Network Connection /0/100/1a bus 82801H (ICH8 Family) USB UHCI Controller #4 /0/100/1a.1 bus 82801H (ICH8 Family) USB UHCI Controller #5 /0/100/1a.7 bus 82801H (ICH8 Family) USB2 EHCI Controller #2 /0/100/1b multimedia 82801H (ICH8 Family) HD Audio Controller /0/100/1c bridge 82801H (ICH8 Family) PCI Express Port 1 /0/100/1c.1 bridge 82801H (ICH8 Family) PCI Express Port 2 /0/100/1c.2 bridge 82801H (ICH8 Family) PCI Express Port 3 /0/100/1c.2/0 storage JMB368 IDE controller /0/100/1d bus 82801H (ICH8 Family) USB UHCI Controller #1 /0/100/1d.1 bus 82801H (ICH8 Family) USB UHCI Controller #2 /0/100/1d.2 bus 82801H (ICH8 Family) USB UHCI Controller #3 /0/100/1d.7 bus 82801H (ICH8 Family) USB2 EHCI Controller #1 /0/100/1e bridge 82801 PCI Bridge /0/100/1e/5 bus FW322/323 [TrueFire] 1394a Controller /0/100/1f bridge 82801HB/HR (ICH8/R) LPC Interface Controller /0/100/1f.2 storage 82801H (ICH8 Family) 4 port SATA Controller [IDE mode] /0/100/1f.3 bus 82801H (ICH8 Family) SMBus Controller /0/100/1f.5 storage 82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE m /0/1 scsi3 storage /0/1/0.0.0 /dev/sda disk 500GB ST3500418AS /0/1/0.0.0/1 /dev/sda1 volume 70GiB Windows NTFS volume /0/1/0.0.0/2 /dev/sda2 volume 395GiB Extended partition /0/1/0.0.0/2/5 /dev/sda5 volume 97GiB HPFS/NTFS partition /0/1/0.0.0/2/6 /dev/sda6 volume 97GiB Linux filesystem partition /0/1/0.0.0/2/7 /dev/sda7 volume 1952MiB Linux swap / Solaris partition /0/1/0.0.0/2/8 /dev/sda8 volume 198GiB Linux filesystem partition /0/3 scsi4 storage /0/3/0.0.0 /dev/cdrom disk DVD RW DRU-190A
The above output is easy to interpret. The system has an intel processor, 4 RAM slots, 1 500gb hard drive with 6 partitions, 1 dvd writer, 1 network adapter, couple of usb ports etc.
The 3rd column is the class name. Lshw can display information only about a particular class if requested with the “-class” options.
3. Display only memory information
To display information about the memory, specify the memory class
$ sudo lshw -short -class memory H/W path Device Class Description =================================================== /0/0/1 memory 2MiB L2 cache /0/0/3 memory 32KiB L1 cache /0/2 memory 32KiB L1 cache /0/4 memory 64KiB BIOS /0/14 memory 8GiB System Memory /0/14/0 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/1 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/2 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/3 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns)
4. Display processor information
With class processor, lshw would display information about the cpu. It is better to not use the short option and get full details about the processor.
$ sudo lshw -class processor *-cpu description: CPU product: Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz vendor: Intel Corp. physical id: 0 bus info: cpu@0 version: Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz slot: LGA 775 size: 2664MHz capacity: 4GHz width: 64 bits clock: 333MHz capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx x86-64 constant_tsc arch_perfmon pebs bts rep_good nopl aperfmperf pni dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 xsave lahf_lm dtherm tpr_shadow vnmi flexpriority cpufreq
It should be noted that lshw does not accurately tell about the number of cores or processing units available. The above system for example is a quadcore processor with 4 processing units. Another command called lscpu gives more accurate information about the cpu. Check out the following post: 8 commands to check cpu information on Linux
5. Disk drives
Display the disk drives with the disk class.
$ sudo lshw -short -class disk [sudo] password for enlightened: H/W path Device Class Description =================================================== /0/1/0.0.0 /dev/sda disk 500GB ST3500418AS /0/3/0.0.0 /dev/cdrom disk DVD RW DRU-190A
To display information about the partitions and controllers also, specify the storage and volume class along with the disk class. Then it would give a more clear picture about the storage on the system.
$ sudo lshw -short -class disk -class storage -class volume H/W path Device Class Description =================================================== /0/100/1c.2/0 storage JMB368 IDE controller /0/100/1f.2 storage 82801H (ICH8 Family) 4 port SATA Controller [IDE mode] /0/100/1f.5 storage 82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE m /0/1 scsi3 storage /0/1/0.0.0 /dev/sda disk 500GB ST3500418AS /0/1/0.0.0/1 /dev/sda1 volume 70GiB Windows NTFS volume /0/1/0.0.0/2 /dev/sda2 volume 395GiB Extended partition /0/1/0.0.0/2/5 /dev/sda5 volume 97GiB HPFS/NTFS partition /0/1/0.0.0/2/6 /dev/sda6 volume 97GiB Linux filesystem partition /0/1/0.0.0/2/7 /dev/sda7 volume 1952MiB Linux swap / Solaris partition /0/1/0.0.0/2/8 /dev/sda8 volume 198GiB Linux filesystem partition /0/3 scsi4 storage /0/3/0.0.0 /dev/cdrom disk DVD RW DRU-190A
6. Network adapter information
Use the network class to display information about the network adapter/interface. Omitting the short option is a good idea to get detailed information about it.
$ sudo lshw -class network *-network description: Ethernet interface product: 82566DC Gigabit Network Connection vendor: Intel Corporation physical id: 19 bus info: pci@0000:00:19.0 logical name: eth0 version: 02 serial: 00:1c:c0:f8:79:ee size: 100Mbit/s capacity: 1Gbit/s width: 32 bits clock: 33MHz capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=2.3.2-k duplex=full firmware=1.1-0 ip=192.168.1.2 latency=0 link=yes multicast=yes port=twisted pair speed=100Mbit/s resources: irq:43 memory:e0300000-e031ffff memory:e0324000-e0324fff ioport:20c0(size=32)
The value of the “serial” field is same as the MAC address. The configuration field indicates that autonegotiation is turned on and the current operating speed is 100Mbit/s. These configurations can be modified with the ethtool command.
7. Display address details with businfo
With the businfo option lshw would output the address details of pci, usb, scsi and ide devices
$ sudo lshw -businfo Bus info Device Class Description ===================================================== system () bus DG35EC cpu@0 processor Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz memory 2MiB L2 cache memory 32KiB L1 cache memory 32KiB L1 cache memory 64KiB BIOS memory 8GiB System Memory memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) pci@0000:00:00.0 bridge 82G35 Express DRAM Controller pci@0000:00:02.0 display 82G35 Express Integrated Graphics Controller pci@0000:00:02.1 display 82G35 Express Integrated Graphics Controller pci@0000:00:19.0 eth0 network 82566DC Gigabit Network Connection pci@0000:00:1a.0 bus 82801H (ICH8 Family) USB UHCI Controller #4 pci@0000:00:1a.1 bus 82801H (ICH8 Family) USB UHCI Controller #5 pci@0000:00:1a.7 bus 82801H (ICH8 Family) USB2 EHCI Controller #2 pci@0000:00:1b.0 multimedia 82801H (ICH8 Family) HD Audio Controller pci@0000:00:1c.0 bridge 82801H (ICH8 Family) PCI Express Port 1 pci@0000:00:1c.1 bridge 82801H (ICH8 Family) PCI Express Port 2 pci@0000:00:1c.2 bridge 82801H (ICH8 Family) PCI Express Port 3 pci@0000:03:00.0 storage JMB368 IDE controller pci@0000:00:1d.0 bus 82801H (ICH8 Family) USB UHCI Controller #1 pci@0000:00:1d.1 bus 82801H (ICH8 Family) USB UHCI Controller #2 pci@0000:00:1d.2 bus 82801H (ICH8 Family) USB UHCI Controller #3 pci@0000:00:1d.7 bus 82801H (ICH8 Family) USB2 EHCI Controller #1 pci@0000:00:1e.0 bridge 82801 PCI Bridge pci@0000:04:05.0 bus FW322/323 [TrueFire] 1394a Controller pci@0000:00:1f.0 bridge 82801HB/HR (ICH8/R) LPC Interface Controller pci@0000:00:1f.2 storage 82801H (ICH8 Family) 4 port SATA Controller [IDE mode] pci@0000:00:1f.3 bus 82801H (ICH8 Family) SMBus Controller pci@0000:00:1f.5 storage 82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE scsi3 storage scsi@3:0.0.0 /dev/sda disk 500GB ST3500418AS scsi@3:0.0.0,1 /dev/sda1 volume 70GiB Windows NTFS volume scsi@3:0.0.0,2 /dev/sda2 volume 395GiB Extended partition /dev/sda5 volume 97GiB HPFS/NTFS partition /dev/sda6 volume 97GiB Linux filesystem partition /dev/sda7 volume 1952MiB Linux swap / Solaris partition /dev/sda8 volume 198GiB Linux filesystem partition scsi4 storage scsi@4:0.0.0 /dev/cdrom disk DVD RW DRU-190A
The output is similar to “short” option, with the first column replaced with Bus Info.
8. Generate report in html/xml format
Lshw is capable of producing reports in html, xml and json formats.
$ sudo lshw -html > hardware.html
For xml format
$ sudo lshw -xml > hardware.xml
检测Linux硬件信息的16个命令
Like for every thing, there are plenty of commands to check information about the hardware of your linux system. Some commands report only specific hardware components like cpu or memory while the rest cover multiple hardware units.
This post takes a quick look at some of the most commonly used commands to check information and configuration details about various hardware peripherals and devices. The list includes lscpu, hwinfo, lshw, dmidecode, lspci etc.
1. lscpu
The lscpu command reports information about the cpu and processing units. It does not have any further options or functionality.
$ lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 23 Stepping: 10 CPU MHz: 1998.000 BogoMIPS: 5302.48 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 2048K NUMA node0 CPU(s): 0-3
2. lshw – List Hardware
A general purpose utility, that reports detailed and brief information about multiple different hardware units such as cpu, memory, disk, usb controllers, network adapters etc. Lshw extracts the information from different /proc files.
$ sudo lshw -short H/W path Device Class Description =================================================== system () /0 bus DG35EC /0/0 processor Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz /0/0/1 memory 2MiB L2 cache /0/0/3 memory 32KiB L1 cache /0/2 memory 32KiB L1 cache /0/4 memory 64KiB BIOS /0/14 memory 8GiB System Memory /0/14/0 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/1 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/2 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/14/3 memory 2GiB DIMM DDR2 Synchronous 667 MHz (1.5 ns) /0/100 bridge 82G35 Express DRAM Controller /0/100/2 display 82G35 Express Integrated Graphics Controller /0/100/2.1 display 82G35 Express Integrated Graphics Controller /0/100/19 eth0 network 82566DC Gigabit Network Connection /0/100/1a bus 82801H (ICH8 Family) USB UHCI Controller #4 /0/100/1a.1 bus 82801H (ICH8 Family) USB UHCI Controller #5 /0/100/1a.7 bus 82801H (ICH8 Family) USB2 EHCI Controller #2 /0/100/1b multimedia 82801H (ICH8 Family) HD Audio Controller /0/100/1c bridge 82801H (ICH8 Family) PCI Express Port 1 /0/100/1c.1 bridge 82801H (ICH8 Family) PCI Express Port 2 /0/100/1c.2 bridge 82801H (ICH8 Family) PCI Express Port 3 /0/100/1c.2/0 storage JMB368 IDE controller /0/100/1d bus 82801H (ICH8 Family) USB UHCI Controller #1 /0/100/1d.1 bus 82801H (ICH8 Family) USB UHCI Controller #2 /0/100/1d.2 bus 82801H (ICH8 Family) USB UHCI Controller #3 /0/100/1d.7 bus 82801H (ICH8 Family) USB2 EHCI Controller #1 /0/100/1e bridge 82801 PCI Bridge /0/100/1e/5 bus FW322/323 [TrueFire] 1394a Controller /0/100/1f bridge 82801HB/HR (ICH8/R) LPC Interface Controller /0/100/1f.2 storage 82801H (ICH8 Family) 4 port SATA Controller [IDE mode] /0/100/1f.3 bus 82801H (ICH8 Family) SMBus Controller /0/100/1f.5 storage 82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE m /0/1 scsi3 storage /0/1/0.0.0 /dev/sda disk 500GB ST3500418AS /0/1/0.0.0/1 /dev/sda1 volume 70GiB Windows NTFS volume /0/1/0.0.0/2 /dev/sda2 volume 395GiB Extended partition /0/1/0.0.0/2/5 /dev/sda5 volume 97GiB HPFS/NTFS partition /0/1/0.0.0/2/6 /dev/sda6 volume 97GiB Linux filesystem partition /0/1/0.0.0/2/7 /dev/sda7 volume 1952MiB Linux swap / Solaris partition /0/1/0.0.0/2/8 /dev/sda8 volume 198GiB Linux filesystem partition /0/3 scsi4 storage /0/3/0.0.0 /dev/cdrom disk DVD RW DRU-190A
Check out the following post to learn more about lshw
Get hardware information on Linux with lshw command
3. hwinfo – Hardware Information
Hwinfo is another general purpose hardware probing utility that can report detailed and brief information about multiple different hardware components, and more than what lshw can report.
$ hwinfo --short cpu: Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz, 2000 MHz Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz, 2000 MHz Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz, 2666 MHz Intel(R) Core(TM)2 Quad CPU Q8400 @ 2.66GHz, 2666 MHz keyboard: /dev/input/event2 AT Translated Set 2 keyboard mouse: /dev/input/mice Microsoft Basic Optical Mouse v2.0 graphics card: Intel 965G-1 Intel 82G35 Express Integrated Graphics Controller sound: Intel 82801H (ICH8 Family) HD Audio Controller storage: Intel 82801H (ICH8 Family) 4 port SATA IDE Controller Intel 82801H (ICH8 Family) 2 port SATA IDE Controller JMicron JMB368 IDE controller network: eth0 Intel 82566DC Gigabit Network Connection network interface: eth0 Ethernet network interface lo Loopback network interface disk: /dev/sda ST3500418AS partition: /dev/sda1 Partition /dev/sda2 Partition /dev/sda5 Partition /dev/sda6 Partition /dev/sda7 Partition /dev/sda8 Partition cdrom: /dev/sr0 SONY DVD RW DRU-190A usb controller: Intel 82801H (ICH8 Family) USB UHCI Controller #4 Intel 82801H (ICH8 Family) USB UHCI Controller #5 Intel 82801H (ICH8 Family) USB2 EHCI Controller #2 Intel 82801H (ICH8 Family) USB UHCI Controller #1 Intel 82801H (ICH8 Family) USB UHCI Controller #2 Intel 82801H (ICH8 Family) USB UHCI Controller #3 Intel 82801H (ICH8 Family) USB2 EHCI Controller #1 bios: BIOS ... TRUNCATED ...
Check out our previous post on hwinfo
Check hardware information on Linux with hwinfo command
4. lspci – List PCI
The lspci command lists out all the pci buses and details about the devices connected to them.
The vga adapter, graphics card, network adapter, usb ports, sata controllers, etc all fall under this category.
$ lspci 00:00.0 Host bridge: Intel Corporation 82G35 Express DRAM Controller (rev 03) 00:02.0 VGA compatible controller: Intel Corporation 82G35 Express Integrated Graphics Controller (rev 03) 00:02.1 Display controller: Intel Corporation 82G35 Express Integrated Graphics Controller (rev 03) 00:19.0 Ethernet controller: Intel Corporation 82566DC Gigabit Network Connection (rev 02) 00:1a.0 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #4 (rev 02) 00:1a.1 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5 (rev 02) 00:1a.7 USB controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2 (rev 02) 00:1b.0 Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 02) 00:1c.0 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 1 (rev 02) 00:1c.1 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 2 (rev 02) 00:1c.2 PCI bridge: Intel Corporation 82801H (ICH8 Family) PCI Express Port 3 (rev 02) 00:1d.0 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1 (rev 02) 00:1d.1 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2 (rev 02) 00:1d.2 USB controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #3 (rev 02) 00:1d.7 USB controller: Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1 (rev 02) 00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev f2) 00:1f.0 ISA bridge: Intel Corporation 82801HB/HR (ICH8/R) LPC Interface Controller (rev 02) 00:1f.2 IDE interface: Intel Corporation 82801H (ICH8 Family) 4 port SATA Controller [IDE mode] (rev 02) 00:1f.3 SMBus: Intel Corporation 82801H (ICH8 Family) SMBus Controller (rev 02) 00:1f.5 IDE interface: Intel Corporation 82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE mode] (rev 02) 03:00.0 IDE interface: JMicron Technology Corp. JMB368 IDE controller 04:05.0 FireWire (IEEE 1394): LSI Corporation FW322/323 [TrueFire] 1394a Controller (rev 70)
Filter out specific device information with grep.
$ lspci -v | grep "VGA" -A 12
5. lsscsi – List scsi devices
Lists out the scsi/sata devices like hard drives and optical drives.
$ lsscsi [3:0:0:0] disk ATA ST3500418AS CC38 /dev/sda [4:0:0:0] cd/dvd SONY DVD RW DRU-190A 1.63 /dev/sr0
6. lsusb – List usb buses and device details
This command shows the USB controllers and details about devices connected to them. By default brief information is printed. Use the verbose option “-v” to print detailed information about each usb port
$ lsusb Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 002: ID 045e:00cb Microsoft Corp. Basic Optical Mouse v2.0 Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
On the above system, 1 usb port is being used by the mouse.
7. Inxi
Inxi is a 10K line mega bash script that fetches hardware details from multiple different sources and commands on the system, and generates a beautiful looking report that non technical users can read easily.
$ inxi -Fx
8. lsblk – List block devices
List out information all block devices, which are the hard drive partitions and other storage devices like optical drives and flash drives
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465.8G 0 disk ├─sda1 8:1 0 70G 0 part ├─sda2 8:2 0 1K 0 part ├─sda5 8:5 0 97.7G 0 part /media/4668484A68483B47 ├─sda6 8:6 0 97.7G 0 part / ├─sda7 8:7 0 1.9G 0 part [SWAP] └─sda8 8:8 0 198.5G 0 part /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1 sr0 11:0 1 1024M 0 rom
9. df – disk space of file systems
Reports various partitions, their mount points and the used and available space on each.
$ df -H Filesystem Size Used Avail Use% Mounted on /dev/sda6 104G 26G 73G 26% / none 4.1k 0 4.1k 0% /sys/fs/cgroup udev 4.2G 4.1k 4.2G 1% /dev tmpfs 837M 1.6M 835M 1% /run none 5.3M 0 5.3M 0% /run/lock none 4.2G 13M 4.2G 1% /run/shm none 105M 21k 105M 1% /run/user /dev/sda8 210G 149G 51G 75% /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1 /dev/sda5 105G 31G 75G 30% /media/4668484A68483B47
10. Pydf – Python df
An improved df version written in python, that displays colored output that looks better than df
$ pydf Filesystem Size Used Avail Use% Mounted on /dev/sda6 96G 23G 68G 24.4 [#.....] / /dev/sda8 195G 138G 47G 70.6 [####..] /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1 /dev/sda5 98G 28G 69G 29.2 [##....] /media/4668484A68483B47
11. fdisk
Fdisk is a utility to modify partitions on hard drives, and can be used to list out the partition information as well.
$ sudo fdisk -l Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x30093008 Device Boot Start End Blocks Id System /dev/sda1 * 63 146801969 73400953+ 7 HPFS/NTFS/exFAT /dev/sda2 146802031 976771071 414984520+ f W95 Ext'd (LBA) /dev/sda5 146802033 351614654 102406311 7 HPFS/NTFS/exFAT /dev/sda6 351614718 556427339 102406311 83 Linux /dev/sda7 556429312 560427007 1998848 82 Linux swap / Solaris /dev/sda8 560429056 976771071 208171008 83 Linux
12. mount
The mount is used to mount/unmount and view mounted file systems.
$ mount | column -t /dev/sda6 on / type ext4 (rw,errors=remount-ro) proc on /proc type proc (rw,noexec,nosuid,nodev) sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) none on /sys/fs/cgroup type tmpfs (rw) none on /sys/fs/fuse/connections type fusectl (rw) none on /sys/kernel/debug type debugfs (rw) none on /sys/kernel/security type securityfs (rw) udev on /dev type devtmpfs (rw,mode=0755) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620) tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755) none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880) none on /run/shm type tmpfs (rw,nosuid,nodev) none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755) none on /sys/fs/pstore type pstore (rw) /dev/sda8 on /media/13f35f59-f023-4d98-b06f-9dfaebefd6c1 type ext4 (rw,nosuid,nodev,errors=remount-ro) /dev/sda5 on /media/4668484A68483B47 type fuseblk (rw,nosuid,nodev,allow_other,blksize=4096) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev) systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd) gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,user=enlightened)
Again, use grep to filter out only those file systems that you want to see
$ mount | column -t | grep ext
13. free – Check RAM
Check the amount of used, free and total amount of RAM on system with the free command.
$ free -m total used free shared buffers cached Mem: 7975 5865 2110 0 24 622 -/+ buffers/cache: 5218 2757 Swap: 1951 921 1030
14. dmidecode
The dmidecode command is different from all other commands. It extracts hardware information by reading data from the SMBOIS data structures (also called DMI tables).
# display information about the processor/cpu $ sudo dmidecode -t processor # memory/ram information $ sudo dmidecode -t memory # bios details $ sudo dmidecode -t bios
Check out the man page for more details.
15. /proc files
Many of the virtual files in the /proc directory contain information about hardware and configurations. Here are some of them
CPU/Memory information
# cpu information $ cat /proc/cpuinfo # memory information $ cat /proc/meminfo
Linux/kernel information
$ cat /proc/version Linux version 3.11.0-12-generic (buildd@allspice) (gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu7) ) #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013
SCSI/Sata devices
$ cat /proc/scsi/scsi Attached devices: Host: scsi3 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: ST3500418AS Rev: CC38 Type: Direct-Access ANSI SCSI revision: 05 Host: scsi4 Channel: 00 Id: 00 Lun: 00 Vendor: SONY Model: DVD RW DRU-190A Rev: 1.63 Type: CD-ROM ANSI SCSI revision: 05
Partitions
$ cat /proc/partitions major minor #blocks name 8 0 488386584 sda 8 1 73400953 sda1 8 2 1 sda2 8 5 102406311 sda5 8 6 102406311 sda6 8 7 1998848 sda7 8 8 208171008 sda8 11 0 1048575 sr0
16. hdparm
The hdparm command gets information about sata devices like hard disks.
$ sudo hdparm -i /dev/sda /dev/sda: Model=ST3500418AS, FwRev=CC38, SerialNo=9VMJXV1N Config={ HardSect NotMFM HdSw>15uSec Fixed DTR>10Mbs RotSpdTol>.5% } RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=4 BuffType=unknown, BuffSize=16384kB, MaxMultSect=16, MultSect=16 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=976773168 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120} PIO modes: pio0 pio1 pio2 pio3 pio4 DMA modes: mdma0 mdma1 mdma2 UDMA modes: udma0 udma1 udma2 udma3 udma4 udma5 *udma6 AdvancedPM=no WriteCache=enabled Drive conforms to: unknown: ATA/ATAPI-4,5,6,7 * signifies the current active mode
Summary
Each of the command has a slightly different method of extracting information, and you may need to try more than one of them, while looking for specific hardware details. However they are available across most linux distros, and can be easily installed from the default repositories.
On the desktop there are gui tools, for those who do not want to memorise and type commands. Hardinfo, I-nex are some of the popular ones that provide detailed information about multiple different hardware components.
16 commands to check hardware information on Linux http://www.binarytides.com/linux-commands-hardware-info/
DMI types
Each hardware component is organized in a separate records with definite type id’s. The DMI specification defines DMI types as follows:
—————————————-
0 BIOS
1 System
2 Base Board
3 Chassis
4 Processor
5 Memory Controller
6 Memory Module
7 Cache
8 Port Connector
9 System Slots
10 On Board Devices
11 OEM Strings
12 System Configuration Options
13 BIOS Language
14 Group Associations
15 System Event Log
16 Physical Memory Array
17 Memory Device
18 32-bit Memory Error
19 Memory Array Mapped Address
20 Memory Device Mapped Address
21 Built-in Pointing Device
22 Portable Battery
23 System Reset
24 Hardware Security
25 System Power Controls
26 Voltage Probe
27 Cooling Device
28 Temperature Probe
29 Electrical Current Probe
30 Out-of-band Remote Access
31 Boot Integrity Services
32 System Boot
33 64-bit Memory Error
34 Management Device
35 Management Device Component
36 Management Device Threshold Data
37 Memory Channel
38 IPMI Device
39 Power Supply
126 Disabled components
127 EOF (End Of File) marker
128-255 OEM-specific data
主板:
lshw -c bus | head dmidecode -t baseboard
BIOS:
dmidecode -t bios
CPU:
less /proc/cpuinfo # 注意这个获得的并不是真实cpu数量,主要看cpu cores 才是真实数目
lshw -c processor dmidecode -t processor
内存:
dmidecode -t memory
硬盘:
lshw -c disk hdparm -I /dev/sda
网卡:
lspci | grep -i eth0 ethtool -i eth0
显卡:
lspci -v | less lshw -c display
USB 裝置:
lsusb
=======================================
显卡详细信息获取:
xrandr --verbose #显示各种支持分辨率 glxgears # 测试显卡驱动的性能
# glx glxdemo glxgears glxheads glxinfo
参考资料:
- debian hardware info – Google 搜索 https://www.google.com.hk/search?q=debian+hardware+info
- debian baseboard info – Google 搜索 https://www.google.com.hk/search?q=debian++baseboard+info
- (总结)Linux下获取详细硬件信息的工具:Dmidecode命令详解 http://www.ha97.com/4120.html
- linux下dmidecode命令获取硬件信息 http://www.ttlsa.com/linux/the-linux-dmidecode-command-to-get-the-hardware-information/
- ru/HowToIdentifyADevice/Motherboard – Debian Wiki https://wiki.debian.org/ru/HowToIdentifyADevice/Motherboard
- Linux commands to find out hardware information. | Securitron Linux blog. http://www.securitronlinux.com/linux/linux-commands-to-find-out-hardware-information/
- Get Hardware Information On Linux Using dmidecode Command | Linux-Support.com http://www.linux-support.com/cms/get-hardware-information-on-linux-using-dmidecode-command/
- Get hardware information on Linux with lshw command http://www.binarytides.com/linux-lshw-command/
- 16 commands to check hardware information on Linux http://www.binarytides.com/linux-commands-hardware-info/
- Inxi is an amazing tool to check hardware information on Linux http://www.binarytides.com/inxi-system-information-linux/
- 8 commands to check cpu information on Linux http://www.binarytides.com/linux-cpu-information/
《“Linux获取硬件信息__工具&命令_集合”》 有 1 条评论
Linux查看分区文件系统类型总结
https://www.cnblogs.com/kerrycode/p/9445608.html
`
在Linux 中如何查看分区的文件系统类型,下面总结几种查看分区文件系统类型的方法。
1: df -T
这个是最简单的命令,文件系统类型在Type列输出。只可以查看已经挂载的分区和文件系统类型。
2: parted -l
parted -l 命令会输出文件系统类型(File system), 其中参数l表示列出所有设备的分区信息。
3: blkid
查看已格式化分区的UUID和文件系统。使用blkid可以输出分区或分区的文件系统类型,查看TYPE字段输出。
4: lsblk -f
有些系统可能没有这个命令,需要安装。注意:lsblk -f也可以查看未挂载的文件系统类型。
`