Как посмотреть usb устройства в linux
Перейти к содержимому

Как посмотреть usb устройства в linux

  • автор:

Ubuntu: список USB-устройств

В Ubuntu вы можете (по той или иной причине) просматривать информацию обо всех USB-устройствах, подключенных к системе. К сожалению, в Ubuntu нет официального USB-инструмента с графическим интерфейсом пользователя, который пользователи могут использовать для эффективного просмотра этой информации.

К счастью, существует множество утилит командной строки, которые пользователи могут использовать для просмотра информации об устройстве USB. В этом руководстве мы рассмотрим каждый из этих инструментов, как они работают и как их использовать.

Список USB-устройств Ubuntu — Lsusb

Первый способ, которым пользователь Ubuntu может просмотреть все подключенные USB-устройства, — это команда lsusb. Эта команда буквально означает «перечислить USB», и она делает именно это — перечисляет все ваши USB-устройства, их идентификаторы, имена и т. Д.

Для начала откройте окно терминала на рабочем столе Ubuntu. Чтобы открыть окно терминала в Ubuntu, нажмите Ctrl + Alt + T на клавиатуре. Или найдите «Терминал» в меню приложения и запустите его таким образом.

Когда окно терминала открыто и готово к использованию, выполните команду lsusb в окне терминала. Как только вы введете его, он распечатает подробную информацию о USB-устройствах, подключенных к системе.

В выходных данных lsusb вы увидите «Шина», за которой следуют числа, «Устройство», другие цифры, «ID», какой-то шестнадцатеричный код (это идентификационный код вашего устройства) и имя устройства. Чтобы найти любое USB-устройство, найдите его имя в конце.

Если вы хотите сохранить этот вывод в текстовый файл для последующего чтения, исследования или более удобного просмотра с помощью вашего любимого текстового редактора, перенаправьте вывод в файл с помощью модификатора командной строки>.

В любое время вы можете просмотреть файл «my-usb-devices.txt» в терминале с помощью приведенной ниже команды cat.

Или откройте текстовый файл в своей домашней папке с помощью вашего любимого текстового редактора.

Список USB-устройств в Ubuntu — Dmesg

Другой способ просмотреть USB-устройства в Ubuntu — использовать команду dmesg. Инструмент dmesg используется в основном для просмотра журналов ядра в вашей системе. Поскольку USB-устройства взаимодействуют с вашей системой Ubuntu, они общаются с ядром Ubuntu Linux, что означает, что их информация находится в этих журналах.

Чтобы использовать dmesg, вы должны сначала открыть окно терминала. Для этого нажмите Ctrl + Alt + T на рабочем столе Ubuntu. Или найдите «Терминал» в меню приложения и запустите его таким образом.

Когда окно терминала открыто и готово к использованию, введите команду dmesg ниже с привилегиями sudo. К сожалению, журналы ядра Ubuntu Linux не могут быть просмотрены без корневого доступа, поскольку dmesg взаимодействует с вещами системного уровня.

Вы увидите вывод всей информации, связанной с USB, которая взаимодействовала с ядром Ubuntu, введя эту команду. Отсюда используйте вывод, чтобы найти информацию о ваших USB-устройствах.

Хотите сохранить вывод dmesg в текстовый файл для последующего чтения или для лучшего просмотра в вашем любимом текстовом редакторе с графическим интерфейсом пользователя? Используя приведенную ниже команду, перенаправьте вывод в текстовый файл.

После перенаправления вы можете просмотреть текстовый файл, используя команду cat ниже. Или открыв «dmesg-usb-info.txt» в вашем любимом текстовом редакторе.

Список Ubuntu USB-устройств — Usb-устройства

Третий способ просмотреть информацию об устройстве USB на рабочем столе Ubuntu — использовать команду usb-devices. Он похож на инструмент lsusb. Однако он немного сложнее и предоставляет гораздо больше информации в гораздо более организованном виде.

Для начала у вас должно быть открыто окно терминала на рабочем столе Ubuntu. Чтобы открыть окно терминала на рабочем столе, нажмите Ctrl + Alt + T на клавиатуре. Или найдите «Терминал» в меню приложения и запустите его.

Когда окно терминала открыто и готово к работе, выполните команду usb-devices. Вывод длинный и подробно распечатывается, каждое USB-устройство, подключенное к Ubuntu, в вертикальном списке.

В этом списке вы увидите несколько столбцов. T, D, P, S, S, S, C и I. Каждая из этих букв содержит массу информации о ваших устройствах. Например, чтобы узнать информацию о производителе подключенного USB-устройства, перейдите к «P» и прочтите информацию о поставщике, продукте и т. Д.

Чтобы сохранить вывод команды usb-devices в вашей системе Ubuntu для последующего чтения или для доступа через ваш любимый текстовый редактор графического интерфейса, вы можете направить вывод с помощью>.

How to List USB Devices Connected to Your Linux System

Mostly, people are interested in knowing what USB devices are connected to the system. This may help troubleshoot the USB devices.

The most reliable way is to use this command:

It shows the webcam, Bluetooth, and Ethernet ports along with the USB ports and mounted USB drives.

list usb with lsusb command linux

But understanding the output of lsusb is not easy and you may not need to complicate things when you just want to see and access the mounted USB drives.

I will show you various tools and commands you can use to list USB devices connected to your system.

I have connected a 2GB pen-drive, 1TB external HDD, Android smartphone via MTP and USB mouse in the examples unless stated otherwise.

Let me start with the simplest of the options for desktop users.

Check connected USB devices graphically

Your distribution file manager can be used to view USB storage devices connected to your computer. As you can see in the screenshot of Nautilus (GNOME File Manager) below.

The connected devices are shown in the sidebar (Only USB Storage devices are shown here).

Nautilus showing connected USB devices

You can also use GUI applications like GNOME Disks or Gparted to view, format, and partition the USB Storage devices connected to your computer. GNOME Disks is preinstalled in most distributions using GNOME Desktop Environment by default.

This app also works as a very good partition manager too.

Use GNOME Disks to list mounted USB devices

Enough of the Graphical tools. Let us discuss the commands you can use for listing the USB devices.

Using the mount command to list the mounted USB devices

The mount command is used for mounting partitions in Linux. You can also list USB storage devices using the same command.

Generally, USB storage is mounted in the media directory. Thus, filtering the output of mount command on media will give you the desired result.

Using df command

df command is a standard UNIX command used to know the amount of available disk space. You can also use this command to list USB storage devices connected using the command below.

Use df command to list mounted USB drives

Using lsblk command

The lsblk command is used to list block devices in the terminal. So, here also by filtering the output containing media keyword, you can get the desired result as shown in the screenshot below.

Using lsblk to list connected USb devicesUsing blkid to list connected USb devices

If you are more curious, you can use the blkid command to know the UUID, Label, Block size etc.

This command gives more output as your internal drives are also listed. So, you have to take references from the above command to identify the device you wish to know about.

Using blkid to list connected USb devices

Using fdisk

fdisk, the good old command line partition manager, can also list the USB storage devices connected to your computer. The output of this command is also very long. So, usually, the connected devices get listed at the bottom as shown below.

Use fidsk to list usb devices

Inspecting /proc/mounts

By inspecting the /proc/mounts file, you can list the USB Storage devices. As you can notice, it shows you the mount options being used by filesystem along with the mount point.

Display all the USB devices with lsusb command

And we revisit the famed lsusb command.

Linux kernel developer Greg Kroah-Hartman developed this handy usbutils utility. This provides us with two commands i.e. lsusb and usb-devices to list USB devices in Linux.

The lsusb command lists all the information about the USB bus in the system.

As you can see this command also shows the Mouse and Smartphone I have connected, unlike other commands (which are capable of listing only USB storage devices).

The second command usb-devices gives more details as compared but fails to list all devices, as shown below.

Greg has also developed a small GTK application called Usbview. This application shows you the list of all the USB devices connected to your computer.

The application is available in the official repositories of most Linux distributions. You can install usbview package using your distribution’s package manager easily.

Once installed, you can launch it from the application menu. You can select any of the listed devices to get details, as shown in the screenshot below.

Conclusion

Most of the methods listed are limited to USB storage devices. There are only two methods which can list other peripherals also; usbview and usbutils. I guess we have one more reason to be grateful to the Linux Kernel developer Greg for developing these handy tools.

I am aware that there are many more ways to list USB devices connected to your system. Your suggestions are welcome.

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 <Enter>. As you can see in the marked section of the screenshot below, the search string is marked white.

You may press <Up> and <Down> 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.

Как посмотреть usb устройства в linux

Команда lsusb позволяет задействовать одноименную утилиту, предназначенную для вывода информации о USB-шинах и подключенных к ним устройствах. Каждое из устройств имеет пару 16-битных идентификаторов: идентификатор производителя (Vendor ID) и идентификатор устройства (Device ID), которые следует использовать для идентификации устройств и поиска драйверов в случае их отсутствия в ядре ОС, а также несколько дополнительных идентификаторов, устанавливаемых производителем. В составе дистрибутивов Linux имеется файл базы данных устройств, содержащий названия устройств с известными идентификаторами. Данная команда крайне полезна для идентификации и диагностики устройств компьютера. Она выводит результаты в формате списка, который может фильтроваться с помощью утилиты grep.

Базовый синтаксис команды выглядит следующим образом:

Утилита может вызываться как без параметров, так и с ними. Наиболее полезными параметрами являются параметр -t, предназначенный для вывода информации в древовидном формате, параметр -v для вывода подробной информации об устройствах, а также параметры -s и -d для вывода информации об устройствах на заданных шинах и с заданными идентификаторами соответственно.

Примеры использования

Вывод списка USB-устройств

Для вывода списка USB-устройств достаточно использовать утилиту без каких-либо параметров. Прав суперпользователя для выполнения команды не требуется.

$ lsusb
Bus 002 Device 005: ID 12d1:1436 Huawei Technologies Co., Ltd. Broadband stick
Bus 002 Device 003: ID 148f:7601 Ralink Technology, Corp. MT7601U Wireless Adapter
Bus 002 Device 002: ID 214b:7250 USB2.0 HUB
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 002: ID 0000:3821 SiliconWin mouse
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 002: ID 04f3:0103 Elan Microelectronics Corp. ActiveJet K-2024 Multimedia Keyboard
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Вывод имеет строго регламентированную структуру. По сути, параметры устройств разделены пробелами. Возьмем последнюю строку в качестве примера:

  • Номер шины: Bus 003
  • Номер устройства на шине: Device 001
  • Идентификаторы производителя и устройства: 1d6b:0001
  • Название устройства: Linux Foundation 1.1 root hub

Несложно убедиться, что все строки имеют схожий формат. При этом в списке отражена информация как об обычных USB-устройствах (таких, как клавиатуры и мыши), так и о специализированных устройствах (таких, как хабы).

Вывод подробной информации о USB-устройствах

Для того, чтобы вывести подробную информацию о USB-устройствах, следует использовать комбинацию параметр -v:

$ lsusb -v

Bus 002 Device 003: ID 148f:7601 Ralink Technology, Corp. MT7601U Wireless Adapter
Couldn’t open device, some information will be missing
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.01
bDeviceClass 0
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x148f Ralink Technology, Corp.
idProduct 0x7601 MT7601U Wireless Adapter
bcdDevice 0.00
iManufacturer 1
iProduct 2
iSerial 3
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 0x004a
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 160mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 8
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x84 EP 4 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x85 EP 5 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x08 EP 8 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x05 EP 5 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x06 EP 6 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x07 EP 7 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x09 EP 9 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0

Данный вывод является крайне обширным и содержит огромное количество параметров конфигурации USB-устройств. Он может использоваться для диагностики и идентификации устройств, причем в случае исполнения команды от лица суперпользователя, информации будет еще больше (обратите внимание на предупреждение в начале вывода).

Вывод информации о заданных USB-шинах и устройствах

Для того, чтобы вывести информацию о заданной USB-шине и устройствах на ней достаточно использовать параметр -s и передать утилите идентификатор интересующей шины:

$ lsusb -s 003:
Bus 003 Device 002: ID 04f3:0103 Elan Microelectronics Corp. ActiveJet K-2024 Multimedia Keyboard
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Или шины и устройства:

$ lsusb -s 003:002
Bus 003 Device 002: ID 04f3:0103 Elan Microelectronics Corp. ActiveJet K-2024 Multimedia Keyboard

При использовании лишь идентификатора шины следует использовать двоеточие в конце идентификатора.

Что касается информации об устройствах, то совместно с параметром -d может использоваться как идентификатор производителя:

$ lsusb -d 04f3:
Bus 003 Device 002: ID 04f3:0103 Elan Microelectronics Corp. ActiveJet K-2024 Multimedia Keyboard

Так и идентификатор устройства:

$ lsusb -d :0103
Bus 003 Device 002: ID 04f3:0103 Elan Microelectronics Corp. ActiveJet K-2024 Multimedia Keyboard

Не стоит забывать о двоеточии, которое указывает на используемый идентификатор: идентификатор производителя должен иметь двоеточие в конце, идентификатор устройства — в начале.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *