mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
20131218-1 选题
This commit is contained in:
parent
0c5102a7ff
commit
a94567a348
@ -0,0 +1,252 @@
|
||||
Linux lsusb Command to Print information about USB on System
|
||||
================================================================================
|
||||
**Universal Serial Bus** or **USB** was designed to standardize the connection of computer peripherals such as keyboards, pointing devices, printers, digital cameras, portable media players, disk drives and network adapters) – Source : [Wikipedia][1]
|
||||
|
||||
![lsusb linux command](http://linoxide.com/wp-content/uploads/2013/12/lsusb-linux-command.jpg)
|
||||
|
||||
Since it becoming a industry standard, now it’s hard to see a computer without USB port on it. The usage of USB Flashdisk makes it more popular. On Linux, we have **lsusb** to list the USB devices and its properties.
|
||||
|
||||
### What is lsusb ###
|
||||
|
||||
From it’s manual page, lsusb is defined as :
|
||||
|
||||
A utility for displaying information about USB buses in the system and the devices connected to them.
|
||||
|
||||
How to run lsusb
|
||||
|
||||
To run lsusb, you can type lsusb directly from console.
|
||||
|
||||
$ lsusb
|
||||
|
||||
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
||||
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
|
||||
Bus 004 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 006 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 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
|
||||
Bus 002 Device 003: ID 17ef:4811 Lenovo Integrated Webcam [R5U877]
|
||||
Bus 008 Device 002: ID 0a5c:217f Broadcom Corp. Bluetooth Controller
|
||||
|
||||
**lsusb** will show you the drivers and device which is internally attach on your system.
|
||||
|
||||
This is how to read the output. I grab the last line from above output :
|
||||
|
||||
#### Bus 008 Device 002 : ID 0a5c:217f Broadcom Corp. Bluetooth Controller ####
|
||||
|
||||
- **Bus 008** : means where the device is attached
|
||||
- **Device 002** : means this is the second device that attach
|
||||
- **ID** : means the ID number of this device
|
||||
- **Broadcom Corp**. Bluetooth Controller : means its manufacture name and device name
|
||||
|
||||
We also see that we also have USB 2.0 root hub drivers and USB 1.1 root hub drivers attach in our system.
|
||||
|
||||
This is also shown using [dmesg][2] command. Here’s an example of it.
|
||||
|
||||
$ dmesg |grep -i usb
|
||||
|
||||
[ 0.353138] usbcore: registered new interface driver usbfs
|
||||
[ 0.353150] usbcore: registered new interface driver hub
|
||||
[ 0.353182] usbcore: registered new device driver usb
|
||||
[ 0.730026] ehci_hcd: USB 2.0 ‘Enhanced’ Host Controller (EHCI) Driver
|
||||
[ 0.730116] ehci_hcd 0000:00:1a.7: new USB bus registered, assigned bus number 1
|
||||
[ 0.748019] ehci_hcd 0000:00:1a.7: USB 2.0 started, EHCI 1.00
|
||||
[ 0.748169] hub 1-0:1.0: USB hub found
|
||||
[ 0.748336] ehci_hcd 0000:00:1d.7: new USB bus registered, assigned bus number 2
|
||||
[ 0.768019] ehci_hcd 0000:00:1d.7: USB 2.0 started, EHCI 1.00
|
||||
[ 0.768147] hub 2-0:1.0: USB hub found
|
||||
[ 0.768236] ohci_hcd: USB 1.1 ‘Open’ Host Controller (OHCI) Driver
|
||||
[ 0.768251] uhci_hcd: USB Universal Host Controller Interface driver
|
||||
|
||||
### How to list USB details ###
|
||||
|
||||
Use **-v** paramater to do it. Here’s a sample of it.
|
||||
|
||||
$ lsusb -v
|
||||
|
||||
Interface Descriptor:
|
||||
bLength 9
|
||||
bDescriptorType 4
|
||||
bInterfaceNumber 1
|
||||
bAlternateSetting 5
|
||||
bNumEndpoints 2
|
||||
bInterfaceClass 224 Wireless
|
||||
bInterfaceSubClass 1 Radio Frequency
|
||||
bInterfaceProtocol 1 Bluetooth
|
||||
iInterface 0
|
||||
Endpoint Descriptor:
|
||||
bLength 7
|
||||
bDescriptorType 5
|
||||
bEndpointAddress 0×83 EP 3 IN
|
||||
bmAttributes 1
|
||||
Transfer Type Isochronous
|
||||
Synch Type None
|
||||
Usage Type Data
|
||||
wMaxPacketSize 0×0040 1x 64 bytes
|
||||
bInterval 1
|
||||
Endpoint Descriptor:
|
||||
bLength 7
|
||||
bDescriptorType 5
|
||||
bEndpointAddress 0×03 EP 3 OUT
|
||||
bmAttributes 1
|
||||
Transfer Type Isochronous
|
||||
Synch Type None
|
||||
Usage Type Data
|
||||
wMaxPacketSize 0×0040 1x 64 bytes
|
||||
bInterval 1
|
||||
|
||||
### Find how many USB devices are connected ###
|
||||
|
||||
To find it use this command
|
||||
|
||||
$ find /dev/bus
|
||||
|
||||
Then you will have an output like this :
|
||||
|
||||
/dev/bus
|
||||
/dev/bus/usb
|
||||
/dev/bus/usb/008
|
||||
/dev/bus/usb/008/002
|
||||
/dev/bus/usb/008/001
|
||||
/dev/bus/usb/007
|
||||
/dev/bus/usb/007/001
|
||||
/dev/bus/usb/006
|
||||
/dev/bus/usb/006/001
|
||||
/dev/bus/usb/005
|
||||
/dev/bus/usb/005/001
|
||||
/dev/bus/usb/004
|
||||
/dev/bus/usb/004/001
|
||||
/dev/bus/usb/003
|
||||
/dev/bus/usb/003/001
|
||||
/dev/bus/usb/002
|
||||
/dev/bus/usb/002/004
|
||||
/dev/bus/usb/002/003
|
||||
/dev/bus/usb/002/001
|
||||
/dev/bus/usb/001
|
||||
/dev/bus/usb/001/001
|
||||
|
||||
Using **lsusb** command **combine with -D** parameter, you can print the detail of specific device. Here’s a sample to view Broadcom Bluetooth device.
|
||||
|
||||
$ lsusb -D /dev/bus/usb/008/002
|
||||
|
||||
Device: ID 0a5c:217f Broadcom Corp. Bluetooth Controller
|
||||
Couldn’t open device, some information will be missing
|
||||
Device Descriptor:
|
||||
bLength 18
|
||||
bDescriptorType 1
|
||||
bcdUSB 2.00
|
||||
bDeviceClass 224 Wireless
|
||||
bDeviceSubClass 1 Radio Frequency
|
||||
bDeviceProtocol 1 Bluetooth
|
||||
bMaxPacketSize0 64
|
||||
idVendor 0x0a5c Broadcom Corp.
|
||||
idProduct 0x217f Bluetooth Controller
|
||||
bcdDevice 3.60
|
||||
iManufacturer 1
|
||||
iProduct 2
|
||||
iSerial 3
|
||||
bNumConfigurations 1
|
||||
Configuration Descriptor:
|
||||
bLength 9
|
||||
bDescriptorType 2
|
||||
wTotalLength 216
|
||||
bNumInterfaces 4
|
||||
bConfigurationValue 1
|
||||
iConfiguration 0
|
||||
bmAttributes 0xe0
|
||||
Self Powered
|
||||
Remote Wakeup
|
||||
MaxPower 0mA
|
||||
Interface Descriptor:
|
||||
bLength 9
|
||||
bDescriptorType 4
|
||||
bInterfaceNumber 0
|
||||
bAlternateSetting 0
|
||||
bNumEndpoints 3
|
||||
bInterfaceClass 224 Wireless
|
||||
bInterfaceSubClass 1 Radio Frequency
|
||||
bInterfaceProtocol 1 Bluetooth
|
||||
iInterface 0
|
||||
Endpoint Descriptor:
|
||||
bLength 7
|
||||
bDescriptorType 5
|
||||
bEndpointAddress 0×81 EP 1 IN
|
||||
bmAttributes 3
|
||||
Transfer Type Interrupt
|
||||
Synch Type None
|
||||
Usage Type Data
|
||||
wMaxPacketSize 0×0010 1x 16 bytes
|
||||
bInterval 1
|
||||
Endpoint Descriptor:
|
||||
bLength 7
|
||||
bDescriptorType 5
|
||||
bEndpointAddress 0×82 EP 2 IN
|
||||
bmAttributes 2
|
||||
Transfer Type Bulk
|
||||
Synch Type None
|
||||
Usage Type Data
|
||||
wMaxPacketSize 0×0040 1x 64 bytes
|
||||
bInterval 1
|
||||
Endpoint Descriptor:
|
||||
bLength 7
|
||||
bDescriptorType 5
|
||||
bEndpointAddress 0×02 EP 2 OUT
|
||||
bmAttributes 2
|
||||
Transfer Type Bulk
|
||||
Synch Type None
|
||||
Usage Type Data
|
||||
wMaxPacketSize 0×0040 1x 64 bytes
|
||||
bInterval 1
|
||||
|
||||
### Find your Mass Storage ###
|
||||
|
||||
Since **lsusb -v** give us a very detail information, you may miss something to read. We can focus to specific information using grep command. Here are some samples.
|
||||
|
||||
Mass storage will have a vendor name and ID. We can use it as a starting point.
|
||||
|
||||
$ lsusb -v |grep -Ei ‘(idVendor|Mass\ Storage)’
|
||||
|
||||
idVendor 0×1005 Apacer Technology, Inc.
|
||||
bInterfaceClass 8 Mass Storage
|
||||
|
||||
You can see, that we have one USB Mass Storage attached on our system from Apacer Technology, Inc.
|
||||
|
||||
### Dump the physical USB device hierarchy as a tree ###
|
||||
|
||||
Use **-t** parameter to fulfill this purpose.
|
||||
|
||||
$ lsusb -t
|
||||
|
||||
/: Bus 08.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
|
||||
/: Bus 07.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
|
||||
/: Bus 06.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
|
||||
/: Bus 05.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
|
||||
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
|
||||
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
|
||||
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/6p, 480M
|
||||
|__ Port 1: Dev 4, If 0, Class=stor., Driver=usb-storage, 480M
|
||||
|__ Port 6: Dev 3, If 0, Class=’bInterfaceClass 0x0e not yet handled’, Driver=uvcvideo, 480M
|
||||
|__ Port 6: Dev 3, If 1, Class=’bInterfaceClass 0x0e not yet handled’, Driver=uvcvideo, 480M
|
||||
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/6p, 480M
|
||||
|
||||
The number **12M and 480M** is **indicate the transfer rate speed** of USB type.
|
||||
|
||||
- 12M means 12Mbit/s which is a USB 1.0 / 1.1 type
|
||||
- 480M means 480Mbit/s which is a USB 2.0 type
|
||||
|
||||
If you found 5.0G, it means that you have USB 3.0 type. It has 5.0Gbit/s transfer rate. Linux recognize the detail of USB devices from **/var/lib/usbutils/usb.ids** . Or you can visit to [Linux-USB.org][3] to get the newest list of USB ID’s.
|
||||
|
||||
That’s all about lsusb command on daily basis. You can use lsusb command to do a diagnostic activity about your USB devices on your system. As usual, you can explore more detail by reading lsusb manual page. Just type **man lsusb** to see its manual page.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-command/linux-lsusb-command-print-usb/
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://en.wikipedia.org/wiki/USB
|
||||
[2]:http://linoxide.com/linux-command/linux-dmesg-command/
|
||||
[3]:http://www.linux-usb.org/usb.ids
|
@ -0,0 +1,112 @@
|
||||
Linux mpstat Command – Reports Processors Related Statistics
|
||||
================================================================================
|
||||
Generally today computer is using multiple processors. Or maybe 1 physical processor with 4 cores inside. On server side, more processors or cores means more power. But the other side, application also more power consumption. You may find a situation when your cpu utilization is high but you feel that you don’t running anything. On Linux system, you can monitor this activity using **mpstat**.
|
||||
|
||||
![linux mpstat command](http://linoxide.com/wp-content/uploads/2013/12/linux-mpstat-command.jpg)
|
||||
|
||||
### What is mpstat ###
|
||||
|
||||
**mpstat** is used to monitor cpu utilization on your system. It will be more usefull if your system has multiple processors. The first processors will signed as CPU 0. The second one will be signed CPU 1 and so on. From its manual page, mpstat is described as :
|
||||
|
||||
> The mpstat command writes to standard output activities for each available processor, processor 0 being the first one. Global average activities among all processors are also reported. The mpstat command can be used both on SMP and UP machines, but in the latter, only global average activities will be printed. If no activity has been selected, then the default report is the CPU utilization report
|
||||
|
||||
### How to run mpstat ###
|
||||
|
||||
Just type **mpstat** on your console to run mpstat.
|
||||
|
||||
$ mpstat
|
||||
|
||||
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
||||
|
||||
03:29:29 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
||||
03:29:29 PM all 6.30 0.06 1.94 3.75 0.00 0.06 0.00 0.00 87.88
|
||||
|
||||
If you found an error such as : **command not found** or similar you may not install mpstat in your system.
|
||||
|
||||
If you are using **CentOS, RedHat or Fedora**, run this command to install mpstat
|
||||
|
||||
# yum install sysstat
|
||||
|
||||
If you are using **Debian, Ubuntu or its derivative**, run this command to install mpstat
|
||||
|
||||
# apt-get install sysstat
|
||||
|
||||
And here’s how to read the information above.
|
||||
|
||||
- **03:29:29 PM** : means the time that mpstat was run
|
||||
- **all** : means All CPUs
|
||||
- **%usr** : show the percentage of CPU utilization that occurred while executing at the user level (application)
|
||||
- **%nice** : show the percentage of CPU utilization that occurred while executing at the user level with nice priority
|
||||
- **%sys** : show the percentage of CPU utilization that occurred while executing at the system level (kernel)
|
||||
- **%iowait** : show the percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request
|
||||
- **%irq** : show the percentage of time spent by the CPU or CPUs to service hardware interrupts
|
||||
- **%soft** : show the percentage of time spent by the CPU or CPUs to service software interrupts
|
||||
- **%steal** : show the percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor
|
||||
- **%guest** : show the percentage of time spent by the CPU or CPUs to run a virtual processor
|
||||
- **%idle** : show the percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O equest
|
||||
|
||||
### Print CPU utilization per processors ###
|
||||
|
||||
As you can see above, our system has 2 CPUs. If you want, you can use -P parameter followed by CPU number to see specific CPU utilization.
|
||||
|
||||
$ mpstat -P 0
|
||||
|
||||
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
||||
|
||||
03:54:00 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
||||
03:54:00 PM 0 3.82 0.01 1.16 3.88 0.00 0.06 0.00 0.00 91.06
|
||||
|
||||
$ mpstat -P 1
|
||||
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
||||
|
||||
03:53:58 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
||||
03:53:58 PM 1 16.52 0.20 4.48 0.46 0.00 0.04 0.00 0.00 78.30
|
||||
|
||||
### Print all CPU Utilization ###
|
||||
|
||||
You can also print every CPU utilization of processors in a single page. Just use **-P ALL** parameter to do it
|
||||
|
||||
$ mpstat -P ALL
|
||||
|
||||
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
||||
|
||||
04:07:36 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
||||
04:07:36 PM all 6.02 0.04 1.72 2.99 0.00 0.05 0.00 0.00 89.17
|
||||
04:07:36 PM 0 3.84 0.01 1.15 3.72 0.00 0.06 0.00 0.00 91.21
|
||||
04:07:36 PM 1 13.55 0.15 3.66 0.46 0.00 0.03 0.00 0.00 82.15
|
||||
|
||||
### Print CPU utilization using intervals ###
|
||||
|
||||
You may want to see the CPU utilization movement. To do this, you can use intervals. Here’s an example.
|
||||
|
||||
$ mpstat 3 4
|
||||
|
||||
Linux 3.2.0-57-generic (USERNB01) 12/12/2013 _x86_64_ (2 CPU)
|
||||
|
||||
04:27:11 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %idle
|
||||
04:27:14 PM all 0.67 0.00 0.34 0.00 0.00 0.00 0.00 0.00 98.99
|
||||
04:27:17 PM all 1.17 0.00 0.33 1.33 0.00 0.00 0.00 0.00 97.17
|
||||
04:27:20 PM all 0.84 0.00 0.17 0.00 0.00 0.00 0.00 0.00 98.99
|
||||
04:27:23 PM all 1.00 0.00 0.17 1.51 0.00 0.00 0.00 0.00 97.32
|
||||
Average: all 0.92 0.00 0.25 0.71 0.00 0.00 0.00 0.00 98.12
|
||||
|
||||
The above command is to show you **4 reports** about CPU utilization with **3 seconds intervals**
|
||||
|
||||
### Print mpstat version ###
|
||||
|
||||
Finally, to print mstat version, use -V parameter
|
||||
|
||||
$ mpstat -V
|
||||
|
||||
sysstat version 10.0.3
|
||||
(C) Sebastien Godard (sysstat orange.
|
||||
|
||||
That’s a quick usage of mpstat command in Linux system. You may see msptat manual page by typing **man mpstat** to explore more detail.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-command/linux-mpstat-command/
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
49
sources/Linux whoami command – Knowing Who is Logged In.md
Normal file
49
sources/Linux whoami command – Knowing Who is Logged In.md
Normal file
@ -0,0 +1,49 @@
|
||||
Linux whoami command – Knowing Who is Logged In
|
||||
================================================================================
|
||||
Generally, on your console you will find a **username is printed** on the command prompt. But in some shell such as **csh**, by default you will not see your username there. So this command particularly is used with the shell which don’t print the username on their shell.
|
||||
|
||||
### How do I run whoami ###
|
||||
|
||||
To run this command, just type whoami. For this sample we are using chs shell.
|
||||
|
||||
% whoami
|
||||
|
||||
![](http://linoxide.com/wp-content/uploads/2013/12/csh.png)
|
||||
|
||||
### Whoami options ###
|
||||
|
||||
This command only have two options. **–help** and **–version**.
|
||||
|
||||
% whoamin –help
|
||||
|
||||
![](http://linoxide.com/wp-content/uploads/2013/12/whoami_help.png)
|
||||
|
||||
This options will output the same information with **man whoami**
|
||||
|
||||
% whoami –version
|
||||
|
||||
![](http://linoxide.com/wp-content/uploads/2013/12/whoami_version.png)
|
||||
|
||||
While **–version** will show you the version of whoami in your system
|
||||
|
||||
### Similarity ###
|
||||
|
||||
Whoami command has the same output with command **id -un**. It also print the username of current user.
|
||||
|
||||
% id -un
|
||||
|
||||
![](http://linoxide.com/wp-content/uploads/2013/12/id-un.png)
|
||||
|
||||
### Conclusion ###
|
||||
|
||||
Whoami command is also used when you are doing su activity (switch user). This command can confirm you that you are logged in using a correct user. Whoami is different with who command. Who command display all logged in user while whoami not. When you are switching user, whoami will reports the current user which the owner of the session, while who command will report you the original user before you are switching user.
|
||||
|
||||
![](http://linoxide.com/wp-content/uploads/2013/12/whoami_vs_who.png)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-command/linux-whoami-command/
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user