mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
translated
This commit is contained in:
parent
db79c422da
commit
d84de28d07
@ -1,185 +0,0 @@
|
||||
[#]: subject: "How to List USB Devices Connected to Your Linux System"
|
||||
[#]: via: "https://itsfoss.com/list-usb-devices-linux/"
|
||||
[#]: author: "Anuj Sharma https://itsfoss.com/author/anuj/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
How to List USB Devices Connected to Your Linux System
|
||||
======
|
||||
How do you list the USB devices in Linux?
|
||||
|
||||
The question can have two meanings.
|
||||
|
||||
* How many USB ports are (detected) on your system?
|
||||
* How many USB devices/disks are mounted (plugged in) to the 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:
|
||||
|
||||
```
|
||||
lsusb
|
||||
```
|
||||
|
||||
It shows the webcam, Bluetooth, and Ethernet ports along with the USB ports and mounted USB drives.
|
||||
|
||||
![list usb with lsusb command linux][1]
|
||||
|
||||
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][2]
|
||||
|
||||
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][3] too.
|
||||
|
||||
![Use GNOME Disks to list mounted USB devices][4]
|
||||
|
||||
*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.
|
||||
|
||||
```
|
||||
mount | grep media
|
||||
```
|
||||
|
||||
![][5]
|
||||
|
||||
### Using df command
|
||||
|
||||
[df command][6] 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.
|
||||
|
||||
```
|
||||
df -Th | grep media
|
||||
```
|
||||
|
||||
![Use df command to list mounted USB drives][7]
|
||||
|
||||
### 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.
|
||||
|
||||
```
|
||||
lsblk | grep media
|
||||
```
|
||||
|
||||
![Using lsblk to list connected USb devicesUsing blkid to list connected USb devices][8]
|
||||
|
||||
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.
|
||||
|
||||
```
|
||||
sudo blkid
|
||||
```
|
||||
|
||||
![Using blkid to list connected USb devices][9]
|
||||
|
||||
### 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.
|
||||
|
||||
```
|
||||
sudo fdisk -l
|
||||
```
|
||||
|
||||
![Use fidsk to list usb devices][10]
|
||||
|
||||
### 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.
|
||||
|
||||
```
|
||||
cat /proc/mounts | grep media
|
||||
```
|
||||
|
||||
![][11]
|
||||
|
||||
### Display all the USB devices with lsusb command
|
||||
|
||||
And we revisit the famed lsusb command.
|
||||
|
||||
Linux kernel developer [Greg Kroah-Hartman][12] developed this handy [usbutils][13] 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.
|
||||
|
||||
```
|
||||
lsusb
|
||||
```
|
||||
|
||||
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).
|
||||
|
||||
![][14]
|
||||
|
||||
The second command `usb-devices` gives more details as compared but fails to list all devices, as shown below.
|
||||
|
||||
```
|
||||
usb-devices
|
||||
```
|
||||
|
||||
![][15]
|
||||
|
||||
Greg has also developed a small GTK application called [Usbview][16]. 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][17] 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.
|
||||
|
||||
![][18]
|
||||
|
||||
### 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.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/list-usb-devices-linux/
|
||||
|
||||
作者:[Anuj Sharma][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/anuj/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://itsfoss.com/wp-content/uploads/2022/08/list-usb-with-lsusb-command-linux.png
|
||||
[2]: https://itsfoss.com/wp-content/uploads/2022/08/nautilus-usb.png
|
||||
[3]: https://itsfoss.com/partition-managers-linux/
|
||||
[4]: https://itsfoss.com/wp-content/uploads/2022/08/gnome-disks-usb.png
|
||||
[5]: https://itsfoss.com/wp-content/uploads/2022/08/mount-cmd-usb.png
|
||||
[6]: https://linuxhandbook.com/df-command/
|
||||
[7]: https://itsfoss.com/wp-content/uploads/2022/08/df-cmd-usb.png
|
||||
[8]: https://itsfoss.com/wp-content/uploads/2022/08/blkid-cmd-usb.png
|
||||
[9]: https://itsfoss.com/wp-content/uploads/2022/08/blkid-cmd-usb.png
|
||||
[10]: https://itsfoss.com/wp-content/uploads/2022/08/fdisk-cmd-usb.png
|
||||
[11]: https://itsfoss.com/wp-content/uploads/2022/08/proc-dir-usb.png
|
||||
[12]: https://en.wikipedia.org/wiki/Greg_Kroah-Hartman
|
||||
[13]: https://github.com/gregkh/usbutils
|
||||
[14]: https://itsfoss.com/wp-content/uploads/2022/08/lsusb-cmd.png
|
||||
[15]: https://itsfoss.com/wp-content/uploads/2022/08/usb-devices-cmd.png
|
||||
[16]: https://github.com/gregkh/usbview
|
||||
[17]: https://itsfoss.com/package-manager/
|
||||
[18]: https://itsfoss.com/wp-content/uploads/2022/08/usbview.png
|
@ -0,0 +1,185 @@
|
||||
[#]: subject: "How to List USB Devices Connected to Your Linux System"
|
||||
[#]: via: "https://itsfoss.com/list-usb-devices-linux/"
|
||||
[#]: author: "Anuj Sharma https://itsfoss.com/author/anuj/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
如何列出连接到 Linux 系统的 USB 设备
|
||||
======
|
||||
你如何列出 Linux 中的 USB 设备?
|
||||
|
||||
这个问题可以有两种含义。
|
||||
|
||||
* 你的系统上有(检测到)多少个 USB 端口?
|
||||
* 系统安装(插入)了多少个 USB 设备/磁盘?
|
||||
|
||||
大多数情况下,人们有兴趣了解哪些 USB 设备连接到系统。这可能有助于对 USB 设备进行故障排除。
|
||||
|
||||
最可靠的方法是使用这个命令:
|
||||
|
||||
```
|
||||
lsusb
|
||||
```
|
||||
|
||||
它显示了网络摄像头、蓝牙和以太网端口以及 USB 端口和挂载的 USB 驱动器。
|
||||
|
||||
![list usb with lsusb command linux][1]
|
||||
|
||||
但是了解 lsusb 的输出并不容易,当你只想查看和访问已挂载的 USB 驱动器时,你可能不需要复杂化。
|
||||
|
||||
我将向你展示可用于列出连接到系统的 USB 设备的各种工具和命令。
|
||||
|
||||
除非另有说明,我在例子中连接了一个 2GB 的 U 盘、1TB 的外置硬盘、通过 MTP 连接的 Android 智能手机和 USB 鼠标。
|
||||
|
||||
让我从桌面用户最简单的选项开始。
|
||||
|
||||
### 以图形方式检查连接的 USB 设备
|
||||
|
||||
你的分发文件管理器可用于查看连接到你的计算机的 USB 存储设备。正如你在下面的 Nautilus(GNOME 文件管理器)的截图中看到的那样。
|
||||
The connected devices are shown in the sidebar (Only USB Storage devices are shown here).
|
||||
连接的设备显示在边栏中(此处仅显示 USB 存储设备)。
|
||||
|
||||
![Nautilus showing connected USB devices][2]
|
||||
|
||||
你还可以使用 GNOME Disks 或 Gparted 等 GUI 应用来查看、格式化和分区连接到计算机的 USB 存储设备。默认情况下,大多数使用 GNOME 桌面环境的发行版都预装了 GNOME Disks。
|
||||
|
||||
这个应用也可以作为一个非常好的[分区管理器][3]。
|
||||
|
||||
![Use GNOME Disks to list mounted USB devices][4]
|
||||
|
||||
*图形工具足够了*。让我们讨论可用于列出 USB 设备的命令。
|
||||
|
||||
### 使用 mount 命令列出挂载的 USB 设备
|
||||
|
||||
mount 命令用于挂载 Linux 中的分区。你还可以使用相同的命令列出 USB 存储设备。
|
||||
|
||||
通常,USB 存储挂载在 media 目录中。因此,在媒体上过滤 mount 命令的输出将为你提供所需的结果。
|
||||
|
||||
```
|
||||
mount | grep media
|
||||
```
|
||||
|
||||
![][5]
|
||||
|
||||
### 使用 df 命令
|
||||
|
||||
[df 命令][6]是一个标准的 UNIX 命令,用于了解可用磁盘空间的大小。你还可以使用此命令列出已连接的 USB 存储设备。
|
||||
|
||||
```
|
||||
df -Th | grep media
|
||||
```
|
||||
|
||||
![Use df command to list mounted USB drives][7]
|
||||
|
||||
### 使用 lsblk 命令
|
||||
|
||||
lsblk 命令用于列出终端中的块设备。因此,这里也通过过滤包含 media 关键字的输出,你可以获得所需的结果,如下面的截图所示。
|
||||
|
||||
```
|
||||
lsblk | grep media
|
||||
```
|
||||
|
||||
![Using lsblk to list connected USb devicesUsing blkid to list connected USb devices][8]
|
||||
|
||||
如果你比较好奇,可以使用 `blkid` 命令了解 UUID、标签、块大小等。
|
||||
|
||||
此命令提供更多输出,因为你的内部驱动器也被列出。因此,你必须参考上述命令来识别你希望了解的设备。
|
||||
|
||||
```
|
||||
sudo blkid
|
||||
```
|
||||
|
||||
![Using blkid to list connected USb devices][9]
|
||||
|
||||
### 使用 fdisk
|
||||
|
||||
fdisk 是一款不错的老式命令行分区管理器,它还可以列出连接到你计算机的 USB 存储设备。这个命令的输出也很长。因此,通常连接的设备会列在底部,如下所示。
|
||||
|
||||
```
|
||||
sudo fdisk -l
|
||||
```
|
||||
|
||||
![Use fidsk to list usb devices][10]
|
||||
|
||||
### 检查 /proc/mounts
|
||||
|
||||
通过检查 /proc/mounts 文件,你可以列出 USB 存储设备。如你所见,它向你显示了文件系统使用的挂载选项以及挂载点。
|
||||
|
||||
```
|
||||
cat /proc/mounts | grep media
|
||||
```
|
||||
|
||||
![][11]
|
||||
|
||||
### 使用 lsusb 命令显示所有 USB 设备
|
||||
|
||||
我们重新审视有名的 lsusb 命令。
|
||||
|
||||
Linux 内核开发人员 [Greg Kroah-Hartman][12] 开发了这个方便的 [usbutils][13] 程序。这为我们提供了两个命令,即 `lsusb` 和 `usb-devices` 来列出 Linux 中的 USB 设备。
|
||||
|
||||
lsusb 命令列出系统中有关 USB 总线的所有信息。
|
||||
|
||||
```
|
||||
lsusb
|
||||
```
|
||||
|
||||
如你所见,此命令还显示了我已连接的鼠标和智能手机,这与其他命令(只能列出 USB 存储设备)不同。
|
||||
|
||||
![][14]
|
||||
|
||||
第二个命令 `usb-devices` 提供了更多详细信息,但未能列出所有设备,如下所示。
|
||||
|
||||
```
|
||||
usb-devices
|
||||
```
|
||||
|
||||
![][15]
|
||||
|
||||
Greg 还开发了一个名为 [Usbview][16] 的小型 GTK 应用。此应用向你显示连接到计算机的所有 USB 设备的列表。
|
||||
|
||||
该应用可在大多数 Linux 发行版的官方仓库中找到。你可以使用发行版的[包管理器][17]轻松安装 `usbview` 包。
|
||||
|
||||
安装后,你可以从应用菜单启动它。你可以选择任何列出的设备以获取详细信息,如下面的截图所示。
|
||||
|
||||
![][18]
|
||||
|
||||
### 总结
|
||||
|
||||
列出的大多数方法仅限于 USB 存储设备。 只有两种方法可以列出其他外围设备; usbview 和 usbutils。 我想我们还有一个理由感谢 Linux Kernel 开发人员 Greg 开发了这些方便的工具。
|
||||
|
||||
我知道还有很多方法可以列出连接到系统的 USB 设备。 欢迎你提出建议。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/list-usb-devices-linux/
|
||||
|
||||
作者:[Anuj Sharma][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/anuj/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://itsfoss.com/wp-content/uploads/2022/08/list-usb-with-lsusb-command-linux.png
|
||||
[2]: https://itsfoss.com/wp-content/uploads/2022/08/nautilus-usb.png
|
||||
[3]: https://itsfoss.com/partition-managers-linux/
|
||||
[4]: https://itsfoss.com/wp-content/uploads/2022/08/gnome-disks-usb.png
|
||||
[5]: https://itsfoss.com/wp-content/uploads/2022/08/mount-cmd-usb.png
|
||||
[6]: https://linuxhandbook.com/df-command/
|
||||
[7]: https://itsfoss.com/wp-content/uploads/2022/08/df-cmd-usb.png
|
||||
[8]: https://itsfoss.com/wp-content/uploads/2022/08/blkid-cmd-usb.png
|
||||
[9]: https://itsfoss.com/wp-content/uploads/2022/08/blkid-cmd-usb.png
|
||||
[10]: https://itsfoss.com/wp-content/uploads/2022/08/fdisk-cmd-usb.png
|
||||
[11]: https://itsfoss.com/wp-content/uploads/2022/08/proc-dir-usb.png
|
||||
[12]: https://en.wikipedia.org/wiki/Greg_Kroah-Hartman
|
||||
[13]: https://github.com/gregkh/usbutils
|
||||
[14]: https://itsfoss.com/wp-content/uploads/2022/08/lsusb-cmd.png
|
||||
[15]: https://itsfoss.com/wp-content/uploads/2022/08/usb-devices-cmd.png
|
||||
[16]: https://github.com/gregkh/usbview
|
||||
[17]: https://itsfoss.com/package-manager/
|
||||
[18]: https://itsfoss.com/wp-content/uploads/2022/08/usbview.png
|
Loading…
Reference in New Issue
Block a user