10 Useful Commands to Collect System and Hardware Information in Linux
Therefore in this tips and tricks, we shall look at some useful commands that can help you to extract information about your Linux system and hardware components.
1. How to View Linux System Information
To know only system name, you can use uname command without any switch will print system information oruname -s command will print the kernel name of your system.
To view your network hostname, use ‘-n’ switch with uname command as shown.
To get information about kernel-version, use ‘-v’ switch.
To get the information about your kernel release, use ‘-r’ switch.
To print your machine hardware name, use ‘-m’ switch:
All this information can be printed at once by running ‘uname -a’ command as shown below.
2. How to View Linux System Hardware Information
Here you can use the lshw tool to gather vast information about your hardware components such as cpu, disks,memory, usb controllers etc.
lshw is a relatively small tool and there are few options that you can use with it while extracting information. The information provided by lshw gathered form different /proc files.
Note: Do remember that the lshw command executed by superuser (root) or sudo user.
Read Also: Difference Between su and sudo User in Linux
To print information about your Linux system hardware, run this command.
You can print a summary of your hardware information by using the -short option.
If you wish to generate output as a html file, you can use the option -html.
3. How to View Linux CPU Information
To view information about your CPU, use the lscpu command as it shows information about your CPU architecture such as number of CPU’s, cores, CPU family model, CPU caches, threads, etc from sysfs and/proc/cpuinfo.
4. How to Collect Linux Block Device Information
Block devices are storage devices such as hard disks, flash drives etc. lsblk command is used to report information about block devices as follows.
If you want to view all block devices on your system then include the -a option.
5. How to Print USB Controllers Information
The lsusb command is used to report information about USB controllers and all the devices that are connected to them.
You can use the -v option to generate a detailed information about each USB device.
6. How to Print PCI Devices Information
PCI devices may included usb ports, graphics cards, network adapters etc. The lspci tool is used to generate information concerning all PCI controllers on your system plus the devices that are connected to them.
To print information about PCI devices run the following command.
Use the -t option to produce output in a tree format.
Use the -v option to produce detailed information about each connected device.
7. How to Print SCSI Devices Information
To view all your scsi/sata devices, use the lsscsi command as follows. If you do not have lsscsi tool installed, run the following command to install it.
After install, run the lsscsi command as shown:
Use the -s option to show device sizes.
8. How to Print Information about SATA Devices
You can find some information about sata devices on your system as follows using the hdparm utility. In the example below, I used the block device /dev/sda1 which the harddisk on my system.
To print information about device geometry interms of cylinders, heads, sectors, size and the starting offset of the device, use the -g option.
9. How to Print Linux File System Information
To gather information about file system partitions, you can use fdisk command. Although the main functionality of fdisk command is to modify file system partitions, it can also be used to view information about the different partitions on your file system.
You can print partition information as follows. Remember to run the command as a superuser or else you may not see any output.
10. How to Extract Information about Hardware Components
You can also use the dmidecode utility to extract hardware information by reading data from the DMI tables.
To print information about memory, run this command as a superuser.
To print information about system, run this command.
To print information about BIOS, run this command.
To print information about processor, run this command.
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
There are many other ways you can use to obtain information about your system hardware components. Most of these commands use files in the /proc directory to extract system information.
Hope you find this tips and tricks useful and remember to post a comment in case you want to add more information to this or if you face any difficulties in using any of the commands. Remember to always stay connected to Tecmint.
No comments:
Post a Comment