mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
翻译完成 4 Useful Way to Know Plugged USB Device Name in Linux (#4704)
* 翻译完成 4 Useful Way to Know Plugged USB Device Name in Linux 翻译完成 * Delete 20161031 4 Useful Way to Know Plugged USB Device Name in Linux.md 翻译完成
This commit is contained in:
parent
ceaa58d417
commit
c5e276e96f
@ -1,102 +0,0 @@
|
||||
###Translating by rusking
|
||||
|
||||
4 Useful Way to Know Plugged USB Device Name in Linux
|
||||
============================================================
|
||||
|
||||
As a newbie, one of the many [things you should master in Linux][1] is identification of devices attached to your system. It may be your computer’s hard disk, an external hard drive or removable media such USB drive or SD Memory card.
|
||||
|
||||
Using USB drives for file transfer is so common today, and for those (new Linux users) who prefer to use the command line, learning the different ways to identify a USB device name is very important, when you need to format it.
|
||||
|
||||
Once you attach a device to your system such as a USB, especially on a desktop, it is automatically mounted to a given directory, normally under /media/username/device-label and you can then access the files in it from that directory. However, this is not the case with a server where you have to[ manually mount a device][2] and specify its mount point.
|
||||
|
||||
Linux identifies devices using special device files stored in `/dev` directory. Some of the files you will find in this directory include `/dev/sda` or `/dev/hda` which represents your first master drive, each partition will be represented by a number such as `/dev/sda1` or `/dev/hda1` for the first partition and so on.
|
||||
|
||||
```
|
||||
$ ls /dev/sda*
|
||||
```
|
||||
[
|
||||
![List All Linux Device Names](http://www.tecmint.com/wp-content/uploads/2016/10/List-All-Linux-Device-Names.png)
|
||||
][3]
|
||||
|
||||
List All Linux Device Names
|
||||
|
||||
Now let’s find out device names using some different command-line tools as shown:
|
||||
|
||||
### Find Out Plugged USB Device Name Using df Command
|
||||
|
||||
To view each device attached to your system as well as its mount point, you can use the [df command][4](checks Linux disk space utilization) as shown in the image below:
|
||||
|
||||
```
|
||||
$ df -h
|
||||
```
|
||||
[
|
||||
![Find USB Device Name Using df Command](http://www.tecmint.com/wp-content/uploads/2016/10/Find-USB-Device-Name.png)
|
||||
][5]
|
||||
|
||||
Find USB Device Name Using df Command
|
||||
|
||||
### Use lsblk Command to Find USB Device Name
|
||||
|
||||
You can also use the [lsblk command (list block devices)][6] which lists all block devices attached to your system like so:
|
||||
|
||||
```
|
||||
$ lsblk
|
||||
```
|
||||
[
|
||||
![List Linux Block Devices](http://www.tecmint.com/wp-content/uploads/2016/10/List-Linux-Block-Devices.png)
|
||||
][7]
|
||||
|
||||
List Linux Block Devices
|
||||
|
||||
### Identify USB Device Name with fdisk Utility
|
||||
|
||||
[fdisk is a powerful utility][8] which prints out the partition table on all your block devices, a USB drive inclusive, you can run it will root privileges as follows:
|
||||
|
||||
```
|
||||
$ sudo fdisk -l
|
||||
```
|
||||
[
|
||||
![List Partition Table of Block Devices](http://www.tecmint.com/wp-content/uploads/2016/10/List-Partition-Table.png)
|
||||
][9]
|
||||
|
||||
List Partition Table of Block Devices
|
||||
|
||||
### Determine USB Device Name with dmesg Command
|
||||
|
||||
dmesg is an important command that prints or controls the kernel ring buffer, a data structure which [stores information about the kernel’s operations][10].
|
||||
|
||||
Run the command below to view kernel operation messages which will as well print information about your USB device:
|
||||
|
||||
```
|
||||
$ dmesg
|
||||
```
|
||||
[
|
||||
![dmesg - Prints USB Device Name](http://www.tecmint.com/wp-content/uploads/2016/10/dmesg-shows-kernel-information.png)
|
||||
][11]
|
||||
|
||||
dmesg – Prints USB Device Name
|
||||
|
||||
That is all for now, in this article, we have covered different approaches of how to find out a USB device name from the command line. You can also share with us any other methods for the same purpose or perhaps offer us your thoughts about the article via the response section below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/find-usb-device-name-in-linux
|
||||
|
||||
作者:[Aaron Kili ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/tag/linux-tricks/
|
||||
[2]:http://www.tecmint.com/mount-filesystem-in-linux/
|
||||
[3]:http://www.tecmint.com/wp-content/uploads/2016/10/List-All-Linux-Device-Names.png
|
||||
[4]:http://www.tecmint.com/how-to-check-disk-space-in-linux/
|
||||
[5]:http://www.tecmint.com/wp-content/uploads/2016/10/Find-USB-Device-Name.png
|
||||
[6]:http://www.tecmint.com/commands-to-collect-system-and-hardware-information-in-linux/
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2016/10/List-Linux-Block-Devices.png
|
||||
[8]:http://www.tecmint.com/fdisk-commands-to-manage-linux-disk-partitions/
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2016/10/List-Partition-Table.png
|
||||
[10]:http://www.tecmint.com/dmesg-commands/
|
||||
[11]:http://www.tecmint.com/wp-content/uploads/2016/10/dmesg-shows-kernel-information.png
|
@ -0,0 +1,100 @@
|
||||
4 Useful Way to Know Plugged USB Device Name in Linux
|
||||
在Linux系统里识别USB设备名字的4种方法
|
||||
============================================================
|
||||
|
||||
对于初学者来说,在Linux系统里你必须掌握的技术之一就是识别出插入系统里的各种设备。这也许是你的系统硬盘,外部的存储设备或者是可移动设备,比如USB设备或SD闪存卡等。
|
||||
|
||||
现如今,使用USB设备来传输文件是十分常见的事,对于那些喜欢使用命令行的新手来说,当你需要格式化USB设备时,学会使用不同的方法来识别USB设备名是非常重要的。
|
||||
|
||||
如果你插入一个设备到你的系统中,尤其是在桌面环境下,比如USB设备,它会自动挂载到一个指定目录,正常情况下是在/media/username/device-label目录下,之后你就可以进入到该目录下访问那些文件了。然而,在服务器上就不是这么回事了,你必须手动挂载这个设备,并且指定一个挂载点。
|
||||
|
||||
Linux系统使用/dev目录下特定的设备文件来标识插入的设备。你会发现该目录下的某些文件,包括/dev/sda或者/dev/sha表示你的第一个主设备,每个分区使用一个数字来表示,比如/dev/sda1或/dev/sha1表示主设备的第一个分区等等。
|
||||
|
||||
```
|
||||
$ ls /dev/sda*
|
||||
```
|
||||
[
|
||||
![List All Linux Device Names](http://www.tecmint.com/wp-content/uploads/2016/10/List-All-Linux-Device-Names.png)
|
||||
][3]
|
||||
|
||||
列出Linux系统下所有的设备名
|
||||
|
||||
现在咱们来使用下面一些特殊的命令行工具找出设备名:
|
||||
|
||||
### 使用df命令来找出插入的USB设备名
|
||||
|
||||
查看插入你系统里的每一个设备及对应的挂载点,你可以使用下图中的df命令检查Linux系统磁盘空间使用情况:
|
||||
|
||||
```
|
||||
$ df -h
|
||||
```
|
||||
[
|
||||
![Find USB Device Name Using df Command](http://www.tecmint.com/wp-content/uploads/2016/10/Find-USB-Device-Name.png)
|
||||
][5]
|
||||
|
||||
使用df命令查找USB设备名
|
||||
|
||||
### 使用lsblk命令查找USB设备名
|
||||
|
||||
你也可以使用下面的lsblk命令(列出块设备)来列出插入你系统里的所有块设备:
|
||||
|
||||
```
|
||||
$ lsblk
|
||||
```
|
||||
[
|
||||
![List Linux Block Devices](http://www.tecmint.com/wp-content/uploads/2016/10/List-Linux-Block-Devices.png)
|
||||
][7]
|
||||
|
||||
列出Linux系统里的块设备
|
||||
|
||||
### 使用fdisk工具识别USB设备名
|
||||
|
||||
fdisk是一个功能强大的工具,用于查看你系统中的所有分区表,包括所有的USB设备,使用root权限执行如下命令:
|
||||
```
|
||||
$ sudo fdisk -l
|
||||
```
|
||||
[
|
||||
![List Partition Table of Block Devices](http://www.tecmint.com/wp-content/uploads/2016/10/List-Partition-Table.png)
|
||||
][9]
|
||||
|
||||
列出块设备的分区表
|
||||
|
||||
### 使用dmesg命令来识别出USB设备名
|
||||
|
||||
dmesg是一个重要的用于打印或者控制内核环形缓冲区的命令。环形缓冲区是一种数据结构,它存放着内核操作数据的信息。
|
||||
|
||||
运行如下的命令来查看内核操作信息,它同时也会打印出USB设备的信息:
|
||||
|
||||
```
|
||||
$ dmesg
|
||||
```
|
||||
[
|
||||
![dmesg - Prints USB Device Name](http://www.tecmint.com/wp-content/uploads/2016/10/dmesg-shows-kernel-information.png)
|
||||
][11]
|
||||
|
||||
dmesg – 打印USB设备名
|
||||
|
||||
以上就是这篇文章中提及到的所有命令,我们在命令行下使用不同的方法来找出USB设备名。你也可以跟大家分享下实现这个目的的其它方法,或者如果你对这篇文章有什么想法也可以在下面跟大家交流下。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/find-usb-device-name-in-linux
|
||||
|
||||
作者:[Aaron Kili ][a]
|
||||
译者:[rusking](https://github.com/rusking)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/tag/linux-tricks/
|
||||
[2]:http://www.tecmint.com/mount-filesystem-in-linux/
|
||||
[3]:http://www.tecmint.com/wp-content/uploads/2016/10/List-All-Linux-Device-Names.png
|
||||
[4]:http://www.tecmint.com/how-to-check-disk-space-in-linux/
|
||||
[5]:http://www.tecmint.com/wp-content/uploads/2016/10/Find-USB-Device-Name.png
|
||||
[6]:http://www.tecmint.com/commands-to-collect-system-and-hardware-information-in-linux/
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2016/10/List-Linux-Block-Devices.png
|
||||
[8]:http://www.tecmint.com/fdisk-commands-to-manage-linux-disk-partitions/
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2016/10/List-Partition-Table.png
|
||||
[10]:http://www.tecmint.com/dmesg-commands/
|
||||
[11]:http://www.tecmint.com/wp-content/uploads/2016/10/dmesg-shows-kernel-information.png
|
Loading…
Reference in New Issue
Block a user