- Lsblk Command in Linux (List Block Devices)
- lsblk command
- Conclusion
- 6 Different Ways to List Hard Drives in Linux
- Listing Hard Drives in Linux
- 2. fdisk
- 3. lsblk
- 4. cfdisk
- 5. parted
- 6. sfdisk
- 16 Commands to Check Hardware Information on Linux
- Hardware information
- 1. lscpu
- 2. lshw — List Hardware
- 3. hwinfo — Hardware Information
- 4. lspci — List PCI
- 5. lsscsi — List scsi devices
- 6. lsusb — List usb buses and device details
- 7. Inxi
- 8. lsblk — List block devices
- 9. df — disk space of file systems
- 10. Pydf — Python df
- 11. fdisk
- 12. mount
- 13. free — Check RAM
- 14. dmidecode
- 15. /proc files
- 16. hdparm
- Summary
- 48 thoughts on “ 16 Commands to Check Hardware Information on Linux ”
- How to Use Linux to Find the Names of the Devices on Your Computer
- Try these commands to show devices on your computer
- Use the ‘mount’ Command
- Use ‘lsblk’ to List Block Devices
- How to List PCI Devices
- List the USB Devices Attached to the Computer
- Summary
Lsblk Command in Linux (List Block Devices)
A Block device is a file referring to a device. The devices can be HDDs, SDD’s, RAM Disks, etc. The block device files can be found under the directory /dev.
In this tutorial, we learn about lsblk command in Linux to list block devices.
lsblk command
lsblk command is used to list information about all available block devices in Linux. lsblk is preinstalled in most Linux Distributions. It comes under the utils-linux package.
Lsblk is normally used to find devices and partitions information. The blkid command can give information such as filesystem and UUID. Whereas df command is used mostly for disk usage and filesystem information.
The simplest form to use lsblk is without any arguments, which will display a list of block devices in a tree format.
lsblk command output with seven columns such as NAME, MAJ:MIN, RM, SIZE, RO, TYPE, and MOUNTPOINT. Each column is explained:
NAME — This is the device name.
MAJ:MIN — This column shows the major and minor device number.
RM — This column shows whether the device is removable or not. Note in this example the device sdb and sr0 have their RM values equals to 1 indicating they are removable.
SIZE — This is column gives information on the size of the device.
RO — This indicates whether a device is read-only. In this case, all devices have a RO=0 indicating they are not read-only.
TYPE — This column shows the block device is a disk or a partition(part) within a disk. In the picture, sda is the disk while sr0 is a read-only memory (rom).
MOUNTPOINT: This column indicates the mount point on which the device is mounted.
Let’s check how to use lsblk command:
01. To list all block devices
Use the option -a to display all devices including empty devices:
02. To change the default lsblk output in tree-like format, use -l option
03. Show specific device
Use lsblk following the device name to display information about a specific device.
04. Display only selective columns
If you want you can display the output of specific columns use the -o option.
For example to list name and size columns type:
05. Display device permissions
You can use lsblk to print each device ownership and permissions using -m option.
06. To Display only SCSI devices use -S option.
07. Display output in ASCII character format.
The default tree format is not user friendly and you can use -i option to display in ASCII format:
08. To display the zone model of each device use -z option.
Conclusion
In this tutorial, we learned how to use lsblk command in Linux to find information about connected block devices. Thanks for reading, please provide your suggestion in the comment section.
Источник
6 Different Ways to List Hard Drives in Linux
There are several ways to list all the hard drives present in a system through Linux command lines.
Keep in mind a hard drive could be physically connected, virtually connected or even emulated (for example: when you use storage devices such as EMC, Sun or IBM).
Here are some different commands which can list the hard drives, keep in mind there are others but these are probably the most commonly used and easy to get the job done.
Listing Hard Drives in Linux
Please note that some of these commands are actually disk partitioning tools and listing disk partition is one of their features.
Let’s see what commands you can use to show disk info in Linux.
The df command in Linux is probably one of the most commonly used. It lists the actual “disk space usage” and it can give you information about what hard disks (or current disk space) is being used in the entire system.
The most common way to use it is with the -h argument which means “human readable” (because we are not machines, right?):
As you can see, the first column is the current logic name (or the name you can find it within your system), the second column is how big is each of them, the third column is how much is currently used (in bytes), the fourth column is how much is currently available in each for usage (in bytes), the fifth column is how much is used (in %) and the sixth and last column is where is it physically mounted in your Linux system.
2. fdisk
fdisk is another common option among sysops. It currently lists the different partitions (which is related to hard drives as a hard drive can be divided into several partitions) in your system.
This will return the entire amount of space (in GB or MB), the entire amount of bytes and the entire amount of sectors per each partition and as a summary, it also gives you the start and end sectors, the amount of disk space (in Bytes) and the type of partition.
Tip: Usually a SATA disk is labelled with sd.
3. lsblk
This one is a little more sophisticated but gets the job done as it lists all block devices. It will give you a very simple list of all devices:
It is probably more visual than the others as it even shows the partitions per each disk in a visual way (like the sda in the example above). It also gives information about the total size per each partition and disk and the physical location for each. This is very commonly used when you need to mount things to be used (like a USB stick or similar) so you can know where is it in order to proceed to mount it.
4. cfdisk
cfdisk is probably the most advanced one in GUI (Graphical User Interface), as it is absolutely visual and interactive. It allows at first to list all disks/partitions in your system but it also allows you to manage them by selecting them and then applying actions such as “Delete”, “Resize”, “Type” (to change partition Type) and “Write” changes done to partitions.
cfdisk example
It also gives you very friendly information about each partition and disk as it gives you where does each partition cylinders start and ends, amount of sectors used by each one and the full size of each one with its type. It won’t give you for example how much is used or free to use.
5. parted
This one is similar to previous ones mentioned, it lists all partitions and allows to manage them. Its main difference is that it also informs you the brand and model of your hard disks and even the type of connectivity used in it (scsi, sata, etc) and total disk size.
6. sfdisk
This is very similar to fdisk, however sfdisk allows you to see both physical and logical volumes and also gives you a “summary” of the actual physical volumes’ partitions with the cylinders (start and end), sectors, size and type.
Probably the “s” is for “super”, as it is a fdisk with super powers:
These commands should allow you to at least see what logical volumes, partitions and hard drives you have in your system and make use of this information for whatever reason you need it, being this just to know more or manipulate any of these.
Most of these commands also give you managing capabilities to modify and manipulate partitions at your will, so make sure to use them with responsibility.
If you like checking system information, do read the article about getting processor information in Linux command line.
If you have any questions or suggestions, do let me know in the comment section.
Источник
16 Commands to Check Hardware Information on Linux
Hardware information
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.
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.
Check out the following post to learn more about lshw
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.
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.
Filter out specific device information with grep.
5. lsscsi — List scsi devices
Lists out the scsi/sata devices like hard drives and optical drives.
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
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.
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
9. df — disk space of file systems
Reports various partitions, their mount points and the used and available space on each.
10. Pydf — Python df
An improved df version written in python, that displays colored output that looks better than df
11. fdisk
Fdisk is a utility to modify partitions on hard drives, and can be used to list out the partition information as well.
12. mount
The mount is used to mount/unmount and view mounted file systems.
Again, use grep to filter out only those file systems that you want to see
13. free — Check RAM
Check the amount of used, free and total amount of RAM on system with the free command.
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).
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
16. hdparm
The hdparm command gets information about sata devices like hard disks.
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.
A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected] .
48 thoughts on “ 16 Commands to Check Hardware Information on Linux ”
How i can check memory in CPU. Example OPT, Efuse
Thanks for this. I’m just getting going on a VPS and this helped me discover they’d not given me the extra 1Gb I ordered. Very well explained.
Super happy with
inxi -Fx
more accurate than some of the other utilities.. for instance hwinfo was inaccurate for my Lenovo
Thanks for the great post!
Thank you! Your descriptions were useful and well explained!
Источник
How to Use Linux to Find the Names of the Devices on Your Computer
Try these commands to show devices on your computer
Listing the devices, drives, PCI devices, and USB devices on your computer involves a series of commands easily invoked from a shell prompt in Linux.
Use the ‘mount’ Command
The most simple syntax you can use is as follows:
The output from the above command is fairly verbose and will be something like this:
Hard drives generally start with /dev/sda or /dev/sdb, so use the grep command to reduce the output as follows:
The results show something like this:
This doesn’t list your drives but it does list your mounted partitions. It doesn’t list partitions that aren’t yet mounted.
The device /dev/sda usually stands for the first hard drive on your system, and if you have a second hard drive, then it will be mounted to /dev/sdb. If you have an SSD, then this will likely be mapped to /dev/sda and the hard drive mapped to /dev/sdb.
Use ‘lsblk’ to List Block Devices
Mount is fine for listing mounted devices, but it doesn’t show every device you have, and the output is verbose, making it difficult to read.
The best way to list the drives in Linux is to use lsblk as follows:
The information displays in a tree format with the following information:
- Name
- Major Minor device number
- Is it removable
- Size
- Is it read-only
- Is it a disk or a partition
- Where is the partition mounted
The display looks something like this:
The information is easier to read. It displays one drive called sda, which offers 50 G of storage. It splits into one partition, called sda1.
The drives fd0 (floppy) and sr0 (CD-ROM) appear in this listing. The particular machine this listing drew from, called mint-vm, is a Linux Mint virtual machine running in the Hyper-V system on a Windows 10 computer. Hyper-V provisions a virtual floppy and CD-ROM drive by default.
How to List PCI Devices
To list the PCI devices use the lspci command as follows:
The output from the above command is verbose, meaning you probably get more information than you need.
Here’s a short snapshot as an example:
The listing lists devices, including VGA controllers, USB controllers, sound, Bluetooth, wireless, and Ethernet controllers.
The standard lspci listing is considered basic, and if you want more detailed information about each device, run the following command:
The information for each device looks something like this:
The output from the lspci -v command is more readable.
You can get even more verbose output by using the following command:
If that isn’t enough information, try the following:
The most useful aspect of lspci, other than listing devices, is the kernel driver used for that device. If the device isn’t working, it is worth researching whether there is a better driver available for the device.
List the USB Devices Attached to the Computer
To list the USB devices available for your computer, use the following command:
The output will be something like this:
If you insert a USB device into the computer, such as an external hard drive, and then run the lsusb command, the device appears on the list.
Summary
The best way to list anything in Linux is to remember the following ls commands:
Источник