
Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: February 21, 2025
Small Computer System Interface (SCSI) is a standard that allows a computer to communicate with physical devices like hard disk drives.
Often, we have multiple drives connected to a single SCSI bus. To differentiate these devices, the Linux kernel assigns SCSI Identifications (IDs) to each.
In this tutorial, we’ll learn how to find SCSI device IDs using Linux commands.
First, we’ll see how the kernel defines SCSI devices. Then, we’ll look at how to find the device IDs in the /sys directory. Finally, we’ll learn the command to get a list with all SCSI device IDs.
Once we plug a SCSI device into the PC, the kernel provides an ID to be able to recognize it later.
The SCSI ID consists of four numbers separated by columns. For example, this is an SCSI ID:
2:0:0:0
Here, the first element is the host number, the second element is the controller number, the third one is the target number, and the final element is the logical unit number.
Now, let’s learn the commands to get the SCSI IDs.
We can list all SCSI device IDs in the /sys/bus/scsi/devices directory using the ls command:
$ ls /sys/bus/scsi/devices
0:0:0:0 2:0:0:0
As can be seen, there are two SCSI devices with the IDs 0:0:0:0 and 2:0:0:0.
Another way of getting the device IDs is by using the lsscsi command.
We may need to install it using the apt command if it’s not already present in our system:
$ sudo apt install lsscsi
Once installed, we can get the list of connected SCSI devices. For that, we use the –scsi_id option:
$ lsscsi --scsi_id
[0:0:0:0] disk ATA KINGSTON SM2280S 01.W /dev/sda -
[2:0:0:0] disk ATA TOSHIBA DT01ACA1 A750 /dev/sdb -
Let’s look at the output in more detail:
As we can see, the output shows information about two connected SCSI devices with their device IDs.
In this article, we learned how to find SCSI device IDs.
First, we looked at how the SCSI ID is defined. Then, we use the /sys directory to find the device IDs. Finally, we learned the lsscspi command to get the list of SCSI devices.