How to check Hardware information, block devices and filesystems on a Linux System
In this tutorial, we will learn how to check hardware information, block devices and filesystems on Linux system.
Many a time as we interact with the Linux system in our day to day activities, there may arise a need to check on the mounted filesystems, available block devices, disk space usage, system hardware information or even file space usage. Well, in this tutorial we are going to explore some of the tools that will come in handy while performing such activities.
You may also want to check our previous article on viewing system processes, memory usage and cpu usage.
Checking Hardware Information
lspci Command
It is used to display all the information about PCI buses in the system and devices connected to them. If run without options, it will display a brief list of devices.
→ lspci 00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09) 00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09) 00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04) 00:16.0 Communication controller: Intel Corporation 7 Series/C216 Chipset Family MEI Controller #1 (rev 04) 00:1a.0 USB controller: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #2 (rev 04) 00:1b.0 Audio device: Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller (rev 04) 00:1c.0 PCI bridge: Intel Corporation 7 Series/C216 Chipset Family PCI Express Root Port 1 (rev c4) 00:1c.1 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 (rev c4) 00:1d.0 USB controller: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #1 (rev 04) 00:1f.0 ISA bridge: Intel Corporation HM76 Express Chipset LPC Controller (rev 04) 00:1f.2 SATA controller: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04) 00:1f.3 SMBus: Intel Corporation 7 Series/C216 Chipset Family SMBus Controller (rev 04) 01:00.0 Ethernet controller: Qualcomm Atheros AR8162 Fast Ethernet (rev 08) 02:00.0 Network controller: Qualcomm Atheros AR9285 Wireless Network Adapter (PCI-Express) (rev 01
However, there are several options that can be used to tweak the output of the program.
- -v – Display detailed information about all devices; can be doubled or tripled (-vv/-vvv) for more verbosity.
- -m – Dump PCI device data in a backward-compatible machine readable form.
- -mm – Dump PCI device data in a machine readable form for easy parsing by scripts.
- -t – Show a tree-like view of all buses, bridges, devices and connections between them.
- -n – Show PCI vendor and device codes as numbers rather than manufacturer and device names.
- -nn – Show PCI both vendor and device names as well their numeric codes.
- – -version – Shows lspci version.
For more options, refer to lspci man pages: lspci(8)
lsusb Command
lsusb utility is used to display information about USB buses in the system and the devices connected to them.
If used without options, it will display basic information about USB devices and attached devices.
→ lsusb Bus 002 Device 003: ID 5986:0294 Acer, Inc Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 004: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller Bus 001 Device 005: ID 0cf3:3005 Qualcomm Atheros Communications AR3011 Bluetooth Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
To display additional information, various options can be passed to the lsusb command.
- -v, – -verbose – Display detailed information about the devices shown.
- -s [[bus]:][devnum] – Show only devices in specified bus and/or device number.
- -d [vendor]:[product] – Show only devices with the specified vendor and product ID.
- -D device – Do not scan the /dev/bus/usb directory, instead display only information about the device whose device file is given.
- -t – Dump the physical USB device hierarchy as a tree.
- -V, – -version – Print version information on standard output, then exit successfully.
lscpu Command
lscpu utility displays information about the CPU cores in the system including their architecture, model, number of cores, vendor ID, etc. To display this information, just run the command, lscpu.
→ 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: 2 Core(s) per socket: 2 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 42 Model name: Intel(R) Core(TM) i3-2370M CPU @ 2.40GHz Stepping: 7 CPU MHz: 1057.763 CPU max MHz: 2400.0000 CPU min MHz: 800.0000 BogoMIPS: 4791.04 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 3072K NUMA node0 CPU(s): 0-3
For more information, check lscpu manual page, lscpu(1)
.
Viewing Block devices and Filesystems
df Command
df utility displays the amount of disk space available on the file system i.e summarizes disk usage on a partition-by-partition basis.
Its syntax is: df [options] [files]
If run without optons, it can display filsystems,type of filesystem, their sizes, used space, available space, percentage space usage, mount point of a filesystem.
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos-root 7923712 1415476 6508236 18% /
devtmpfs 497924 0 497924 0% /dev
tmpfs 508384 0 508384 0% /dev/shm
tmpfs 508384 6780 501604 2% /run
tmpfs 508384 0 508384 0% /sys/fs/cgroup
/dev/vda1 508588 127184 381404 26% /boot
tmpfs 101680 0 101680 0% /run/user/0
Some of the options that can be used to fine-tune the output of the df command include but no limited to:
- -h, – -human-readable – Print sizes in powers of 1024 (e.g., 1023M).
- -H, – -si – Print sizes in powers of 1000 (e.g., 1.1G).
- -i, – -inodes – List inode information instead of block usage.
- -l, – -local – Limit listing to local file systems.
- -T, – -print-type – Print file system type.
- – -help – Display help and exit.
- – -version – Displays version information and exit.
Consult man page, df(1)
, for more options that can be used.
An Example to display filesystem types in human readable form i.e display sizes in either megabytes or gigabytes instead of blocks;
# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 7.6G 1.4G 6.3G 18% /
devtmpfs devtmpfs 487M 0 487M 0% /dev
tmpfs tmpfs 497M 0 497M 0% /dev/shm
tmpfs tmpfs 497M 6.7M 490M 2% /run
tmpfs tmpfs 497M 0 497M 0% /sys/fs/cgroup
/dev/vda1 xfs 497M 125M 373M 26% /boot
tmpfs tmpfs 100M 0 100M 0% /run/user/0
du Command
Summarize disk usage of the set of FILEs, recursively for directories. It searches the specified directories recursively and reports how much disk space each is consuming.
The basic syntax is: du [options] [directories]
To display the disk usage for each of the subdirectories in the current working directory, run the command with no option:
→ du
40 ./man
136 ./src
28 ./src.drivers/freebsd
28 ./src.drivers
16 ./test
228 .
Some of the options used include:
- -a, – -all – Write counts for all files, not just directories
- -c, – -total – Produce a grand total at the end of its output.
- -h, – -human-readable – Print sizes in human readable format (e.g., 2K 110M 34G)
- – -help – Display this help and exit
- – -version – Displays version information and exit
For more options, consult du man page, du(1)
.
To display grand total in human readable form, pass option -h and -c;
→ du -hc
40K ./man
136K ./src
28K ./src.drivers/freebsd
28K ./src.drivers
16K ./test
228K .
228K total
blkid Command
blkid command displays information such as UUID, filesystem type, volume label about available block devices. For example:
(Remember, you must run blkid with root privileges).
→ sudo blkid
/dev/sda1: UUID="79D9-BCB0" TYPE="vfat" PARTLABEL="efi-partition" PARTUUID="93faccbe-ced7-4558-87f0-00611ca851a3"
/dev/sda2: UUID="b3bc5ae7-4e21-4ebe-a7e2-e87a1b973855" TYPE="ext2" PARTLABEL="boot-partition" PARTUUID="9dfb1f4b-5c99-40c4-b72a-f1e27c8ad428"
/dev/sda3: UUID="3nWuw6-VbTt-oulx-W7lO-gglc-M0bN-tCm6wW" TYPE="LVM2_member" PARTUUID="b8d581fd-9879-4450-ac5d-09f0152c31df"
/dev/sda4: UUID="Hksbm5-Vcwf-bBvp-tY69-KSeo-9s5r-TX0uNk" TYPE="LVM2_member" PARTUUID="277b8838-5fd0-41e7-85d4-b97213f72e29"
/dev/mapper/arch--lvm-arch--root: LABEL="root" UUID="4901c483-686c-41e0-8a0b-439b11691096" UUID_SUB="0da921ad-198f-46c8-805c-b3fe43bcc306" TYPE="btrfs"
/dev/mapper/arch--lvm-arch--swap: UUID="e29a12d7-eb52-4120-808e-aa82bc22fa88" TYPE="swap"
/dev/mapper/arch--lvm-arch--home: LABEL="home" UUID="7fe682b6-e4f6-4a9e-aa8e-7fbd7e0976b1" UUID_SUB="d3f07989-7463-48a5-b817-38526d6eecbc" TYPE="btrfs"
To display specific information about specific block device, pass the device name to blkid. For example, to display information about /dev/sda2/
→ sudo blkid /dev/sda2
/dev/sda2: UUID="b3bc5ae7-4e21-4ebe-a7e2-e87a1b973855" TYPE="ext2" PARTLABEL="boot-partition" PARTUUID="9dfb1f4b-5c99-40c4-b72a-f1e27c8ad428"
To see the options that can be used with blkid, check its man page.
lsblk Command
It lists information such as name, major and minor number, if the device is removable, size, type, if the device is read only and the mount point of all or specified block device. See the example below.
→ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 465.8G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
├─sda2 8:2 0 287M 0 part /boot
├─sda3 8:3 0 249.2G 0 part
│ ├─arch--lvm-arch--root 254:0 0 109.8G 0 lvm /
│ ├─arch--lvm-arch--swap 254:1 0 5G 0 lvm
│ └─arch--lvm-arch--home 254:2 0 233G 0 lvm /home
└─sda4 8:4 0 215.8G 0 part
├─arch--lvm-arch--root 254:0 0 109.8G 0 lvm /
└─arch--lvm-arch--home 254:2 0 233G 0 lvm /home
sr0 11:0 1 1024M 0 rom
There are several options that can be used with lsblk command. Check its man pages.
findmnt Command
findmnt command is used to list all mounted filesystems or search for a filesystem along with the information such as target mount point, source device, filesystem type and relevant mount options. If device or mountpoint is not given, all filesystems are shown in the tree-like format.
→ findmnt
TARGET SOURCE FSTYPE OPTIONS
/ /dev/mapper/arch--lvm-arch--root
│ btrfs rw,relatime,space_cache,subvolid=5,subvol=/
├─/proc proc proc rw,nosuid,nodev,noexec,relatime
│ └─/proc/sys/fs/binfmt_misc systemd-1 autofs rw,relatime,fd=27,pgrp=1,timeout=0,minproto=5,maxproto=5,direct
├─/sys sys sysfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/security securityfs securityfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/fs/cgroup tmpfs tmpfs ro,nosuid,nodev,noexec,mode=755
│ │ ├─/sys/fs/cgroup/systemd cgroup cgroup rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent
│ │ ├─/sys/fs/cgroup/cpu,cpuacct cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpu,cpuacct
│ │ ├─/sys/fs/cgroup/cpuset cgroup cgroup rw,nosuid,nodev,noexec,relatime,cpuset
│ │ ├─/sys/fs/cgroup/freezer cgroup cgroup rw,nosuid,nodev,noexec,relatime,freezer
│ │ ├─/sys/fs/cgroup/net_cls cgroup cgroup rw,nosuid,nodev,noexec,relatime,net_cls
│ │ ├─/sys/fs/cgroup/memory cgroup cgroup rw,nosuid,nodev,noexec,relatime,memory
│ │ ├─/sys/fs/cgroup/pids cgroup cgroup rw,nosuid,nodev,noexec,relatime,pids
│ │ ├─/sys/fs/cgroup/blkio cgroup cgroup rw,nosuid,nodev,noexec,relatime,blkio
│ │ └─/sys/fs/cgroup/devices cgroup cgroup rw,nosuid,nodev,noexec,relatime,devices
│ ├─/sys/fs/pstore pstore pstore rw,nosuid,nodev,noexec,relatime
│ ├─/sys/firmware/efi/efivars efivarfs efivarfs rw,nosuid,nodev,noexec,relatime
│ ├─/sys/kernel/debug debugfs debugfs rw,relatime
│ ├─/sys/kernel/config configfs configfs rw,relatime
│ └─/sys/fs/fuse/connections fusectl fusectl rw,relatime
├─/dev dev devtmpfs rw,nosuid,relatime,size=1965472k,nr_inodes=491368,mode=755
│ ├─/dev/shm tmpfs tmpfs rw,nosuid,nodev
│ ├─/dev/pts devpts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
│ ├─/dev/hugepages hugetlbfs hugetlbfs rw,relatime
│ └─/dev/mqueue mqueue mqueue rw,relatime
├─/run run tmpfs rw,nosuid,nodev,relatime,mode=755
│ └─/run/user/1000 tmpfs tmpfs rw,nosuid,nodev,relatime,size=394576k,mode=700,uid=1000,gid=1000
│ └─/run/user/1000/gvfs gvfsd-fuse fuse.gvfsd-fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000
├─/tmp tmpfs tmpfs rw,nosuid,nodev
├─/home /dev/mapper/arch--lvm-arch--home
│ btrfs rw,relatime,space_cache,subvolid=5,subvol=/
└─/boot /dev/sda2 ext2 rw,relatime,block_validity,barrier,user_xattr,acl,stripe=4
└─/boot/efi /dev/sda1 vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed
There are other commands such as free command that can be used to check memory usage. It displays the total amount of physical and swap memory in the system as well as amount of used, free, shared, cached or in kernel buffers. There are several options that can be used with free command. Check details on its man pages.
free -hm
total used free shared buff/cache available
Mem: 992M 111M 617M 7.0M 263M 726M
Swap: 923M 0B 923M
Reacties
Een reactie posten