Commands tagged usb (5)

  • You have an external USB drive or key. Apply this command (using the file path of anything on your device) and it will simulate the unplug of this device. If you just want the port, just type : echo $(sudo lshw -businfo | grep -B 1 -m 1 $(df "/path/to/file" | tail -1 | awk '{print $1}' | cut -c 6-8) | head -n 1 | awk '{print $1}' | cut -c 5- | tr ":" "-") Show Sample Output

    echo $(sudo lshw -businfo | grep -B 1 -m 1 $(df "/path/to/file" | tail -1 | awk '{print $1}' | cut -c 6-8) | head -n 1 | awk '{print $1}' | cut -c 5- | tr ":" "-") | sudo tee /sys/bus/usb/drivers/usb/unbind
    tweet78 · 2014-04-06 12:06:29 16
  • Some times you may ban usb to protect thefting of your personal data. Blacklist the usb_storage module by adding blacklist usb_storage to /etc/modprobe.d/blacklist.conf. To load the module manually, sudo modprobe usb_storage.

    blacklist usb_storage >> /etc/modprobe.d/blacklist.conf
    totti · 2013-02-01 09:38:43 22
  • This command lists the names of your USB devices connected and what file in /dev they are using. It's pretty useful if you don't have an automount option in your desktop or you don't have any graphical enviroment. Show Sample Output

    ls -la /dev/disk/by-id/usb-*
    casidiablo · 2009-11-25 16:02:06 2
  • If you don't want your computer to try to boot form a USB stick that used to be used as a boot device (maybe for a live linux distro), you will have to remove the boot loader from your stick other wise the boot will fail each time the device is attached to your PC.

    dd if=/dev/zero of=/dev/sdb bs=446 count=1
    dcabanis · 2009-06-07 10:29:49 5
  • Usage: VBoxBlockBoot [Virtual_Machine] [Block_device] Eg: VBoxBlockBoot WinXP /dev/sdc In another words vm=usb; usb=sdc;sudo umount /dev/$usb* ; sudo chmod 777 /dev/$usb ; VBoxManage storageattach $vm --medium ~/raw-HD-4-VB/$usb.vmdk --type hdd --storagectl "IDE Controller" --device 0 --port 0 ; VBoxManage startvm $vm Where vm --> Name of the virtual machine to start usb --> Block device to use. (/dev/sdc) This can used after setup up a boot loader on to my USB pen drive or HDD (After creating Live USB). Here root privilege is needed but not granted to Virtual Box. Thus we can access all our VM.( If we run VBox as root we can't access our VMs). Root privilege is used to - Unmount the storage device - Chmod to full access (777) Requirements:- 1. Device information file (rawvmdk file) created by the following command. Need to run only once. Not bad to run many. VBoxCreateRawDisk() { VBoxManage internalcommands createrawvmdk -filename ~/.rawHD4VB_`basename "$1"`.vmdk -rawdisk "$1"; } 2. Root privilege to umount & chmod 3. Real storage medium (ie /dev/*) (Non-virtual such as USB HD, pen drive, a partition) 4. A virtual m/c already available (here "usb") vm=usb; usb=sdc;sudo umount /dev/$usb* ; sudo chmod 777 /dev/$usb ; VBoxManage storageattach $vm --medium ~/raw-HD-4-VB/$usb.vmdk --type hdd --storagectl "IDE Controller" --device 0 --port 0 ; VBoxManage startvm $vm VBoxBlockBoot() { sudo umount "$2"*; sudo chmod 777 "$2"; VBoxManage storageattach "$1" --medium ~/.rawHD4VB_`basename "$2"`.vmdk --type hdd --storagectl "IDE Controller" --device 0 --port 0 ; VBoxManage startvm "$1"; } Show Sample Output

    VBoxBlockBoot() { sudo umount "$2"*; sudo chmod 777 "$2"; VBoxManage storageattach "$1" --medium ~/.rawHD4VB_`basename "$2"`.vmdk --type hdd --storagectl "IDE Controller" --device 0 --port 0 ; VBoxManage startvm "$1";}
    totti · 2011-07-29 13:04:19 3

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Check These Out

find duplicate processes
This command will allow to search for duplicate processes and sort them by their run count. Note that if there are same processes run by different users you'll see only one user in the result line, so you'll need to do: $ ps aux | grep to see all users that run this command.

list files recursively by size

Print trending topics on Twitter

Print current running shell, PID
works as well as echo $0, but also prints process id, which pts you're using. echo $SHELL doesn't always get updated when changing shells, so this is a better solution than that. Just one more variation on a theme.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Alias TAIL for automatic smart output
Run the alias command, then issue $ps aux | tail and resize your terminal window (putty/console/hyperterm/xterm/etc) then issue the same command and you'll understand. $ ${LINES:-`tput lines 2>/dev/null||echo -n 12`} Insructs the shell that if LINES is not set or null to use the output from `tput lines` ( ncurses based terminal access ) to get the number of lines in your terminal. But furthermore, in case that doesn't work either, it will default to using the default of 80. The default for TAIL is to output the last 10 lines, this alias changes the default to output the last x lines instead, where x is the number of lines currently displayed on your terminal - 7. The -7 is there so that the top line displayed is the command you ran that used TAIL, ie the prompt. Depending on whether your PS1 and/or PROMPT_COMMAND output more than 1 line (mine is 3) you will want to increase from -2. So with my prompt being the following, I need -7, or - 5 if I only want to display the commandline at the top. ( ) 275MB/748MB [7995:7993 - 0:186] 06:26:49 Thu Apr 08 [askapache@n1-backbone5:/dev/pts/0 +1] ~ $ In most shells the LINES variable is created automatically at login and updated when the terminal is resized (28 linux, 23/20 others for SIGWINCH) to contain the number of vertical lines that can fit in your terminal window. Because the alias doesn't hard-code the current LINES but relys on the $LINES variable, this is a dynamic alias that will always work on a tty device.

Output the content of your Active Directory in a CSV file

Processes by CPU usage

Log the current memory statistics frequently to syslog
Uses logger in a while loop to log memory statistics frequently into the local syslog server.

Convert seconds into minutes and seconds
This is a very simple way to input a large number of seconds and get a more useful value in minutes and seconds.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: