- How to List all Linux Disk Devices
- How to list disk devices in Linux with lsblk
- Lsblk, The column NAME:
- Lsblk, The column MAJ:MIN:
- Lsblk, The column RM:
- Lsblk, The column SIZE:
- Lsblk, The column RO:
- Lsblk, The column TYPE:
- Lsblk, The column MOUNTPOINT:
- How to show free and used space in Linux disk devices
- About the author
- David Adams
- 6 Different Ways to List Hard Drives in Linux
- Listing Hard Drives in Linux
- 2. fdisk
- 3. lsblk
- 4. cfdisk
- 5. parted
- 6. sfdisk
- List USB Devices Linux
- Listing USB Devices using lsusb Command
- Listing USB devices with usb-devices Command
- Listing Block USB Devices
How to List all Linux Disk Devices
How to list disk devices in Linux with lsblk
The proper way to list block devices such as hard disks is using the command lsblk.
Note: the -a flag forces lsblk to list also empty devices.
In the first column you can see all the connected devices, in the image above you can see 3 devices: sda, sdc and sdd. Lets see some information on each.
Lsblk, The column NAME:
The NAME column shows the name of each disk device and partition. As you can see in the extract of the column below the disk SDA contains 4 partitions: sda1, sda2, sda3 and sda4. You can ignore the “_crypt_” for now.
The second listed disk device is sdc with only one partition, sdc1.
The second listed disk device is sdd with only one partition, sdd1.
The last listed device is the DVD or CDROM:
Lsblk, The column MAJ:MIN:
Following the column NAME there is the column MAJ:MIN is the internal identificator for each device the kernel uses according to the device type.
Lsblk, The column RM:
The column RM shows if the device is removable (where 1 yes and 0 no), in this case last 2 disk are external and the last device is the DVD.
Lsblk, The column SIZE:
The column SIZE displays the size of each of the disk devices listed.
Lsblk, The column RO:
The column RO means Read Only, being 1 positive and 0 negative, if 0 then devices are not read only, if 1, they are read-only.
Lsblk, The column TYPE:
The column TYPE displays the type of device such as devices, partitions, optical devices, encrypted partitions and more.
Lsblk, The column MOUNTPOINT:
The column MOUNTPOINT shows the mount point of each device or partition, the next image shows the partitions of the device sda.
The screenshot below shows an efi partition belonging to sda1, the encrypted sda2 root partition, the sda3 for boot and an encrypted sda4 SWAP.
The flag -l will show the devices and partition as a list rather than as tree:
The flag -f instructs lsblk to inform the filesystem of each partition:
Additional flags for the command lsblk are available and explained in the man page which you can also access at https://linux.die.net/man/8/lsblk.
Listing disk devices in Linux with alternative methods: fdisk and fstab
While the correct way to list disk devices in Linux is using the command lsblk, other options are available.
The first one to try is fdisk, to list all block devices with fdisk run:
How to show free and used space in Linux disk devices
Additionally to listing your storage devices you may need to show the free and used space, this can be achieved using the command df.
As you see in the screenshot below, the availability of space of all disks formerly listed is now displayed.
The command df allows you to easily check each partition identified both by its device name or its mountpoint, yet, the -h option makes it easier to be readed by humans.
For example the image above shows the partition /dev/sda2_crypt which is the root mount point / has 150 GB available and 64 GB used.
About the author
David Adams
David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.
Источник
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.
Источник
List USB Devices Linux
In the world of USB computer peripherals, almost everyone uses some sort of USB devices in their computer. These days there are USB webcams, USB hard drives, USB stick also known as PenDrive etc. Almost every device has a USB version of it. So if you’re using Linux, listing what USB device is connected to your system might be necessary at some point.
There are many programs and many ways to list USB devices on Linux.
In this article, I will show you how to list USB devices on Linux. I am using Ubuntu 18.04 Bionic Beaver for the demonstration, but these commands are available on every Linux distribution. So let’s get started.
Listing USB Devices using lsusb Command
The widely used lsusb command can be used to list all the connected USB devices in Linux.
As you can see from the output of the lsusb command in the screenshot below, all the connected USB device is listed. The Bus ID, Device ID, USB ID, and a title is displayed in the output of lsusb command.
As you can see in the marked section of the screenshot below, Realtek Semiconductor Corp. with ID 0bda:57cb, this is my USB Webcam.
You can’t tell that it’s a Webcam by looking at the output of lsusb command, Can you? Nope! So how do I know this? It’s because I checked the output of the lsusb command before and after connecting the USB Webcam and once I compared the outputs, the newly added row is the USB device I connected. Plain! But there are ways to find out what the USB device is.
You can use the dmesg command to find out more information about the connected USB devices. The last connected USB device is the easiest to find with dmesg command. It is more widely used for debugging purpose. You will shortly see why.
You run dmesg command as follows:
As you can see in the yellow marked box in the screenshot below, these are information about the USB device I connected last, which was my USB Webcam. You can see in one of the blue marked box, the USB device I connected is a HD UVC WebCam and its ID is 0bda:57cb.
By now you may have found out that the output of dmesg command is system log messages. Well yes, it is.
You can also search for a specific USB device by its ID in the dmesg system log.
Run the following command to open the output of dmesg command with less text pager:
You should see the following window:
Now to search for a string, press / key on your keyboard. And you should the a / appear on the bottom of terminal window as marked in the screenshot below.
Now type in the USB device ID. For example, earlier when I listed the connected USB devices with lsusb command, one of the USB device had ID 0bda:57cb
Type in the USB Device ID and press . As you can see in the marked section of the screenshot below, the search string is marked white.
You may press and arrow keys to navigate up and down and read through it. You should find a lot of information about that USB device as you can see in the marked section of the screenshot below.
Listing USB devices with usb-devices Command
You can run the following command to list all the connected USB devices of your system:
As you can see in the screenshot below, all the connected USB devices are listed. we can find out pretty much the same information as before with usb-devices command.
Listing Block USB Devices
If you want to list all the USB block storage devices, that is all the USB storage devices, then you can use the lsblk or fdisk command to do so.
Listing USB block storage devices with lsblk:
As you can see in the screenshot below, all the available block storage devices (including the USB block storage devices) are listed.
You can get almost the same information as lsblk command with blkid command. But you have to run it as root as follows:
You can also use fdisk command to list all the USB block storage devices as follows:
As you can see in the screenshot below, the connected block storage devices (including the USB devices) are listed.
That’s how you list all the USB devices on Linux. Thanks for reading this article.
Источник