Power OFF and ON USB device in linux (ubuntu)

There are two methods of doing this. So first method is for kernels after 2.6.32, and second for older ones. To view kernel version, simply enter:
1 2 |
> uname -r 3.8.0-29-generic |
find Your USB device, no mather what it is USB flash drive, Yubikey, USB disk drive:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
> lsusb Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub 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 002 Device 005: ID 12d1:14db Huawei Technologies Co., Ltd. Bus 002 Device 006: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub > lsusb -t /: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M |__ Port 1: Dev 5, If 0, Class=comm., Driver=cdc_ether, 480M |__ Port 1: Dev 5, If 1, Class=data, Driver=cdc_ether, 480M |__ Port 5: Dev 6, If 0, Class=hub, Driver=hub/4p, 480M /: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/6p, 480M |