Commands by jp (2)

  • Need output in mbps (bits) # ./bytes-second.sh eth0 eth0 interface maximum Speed: 1000Mb/s RX:12883212 TX:17402002 B/s | RX:98 TX:132 Mb/s RX:12371647 TX:17830111 B/s | RX:94 TX:136 Mb/s RX:12502750 TX:17860915 B/s | RX:95 TX:136 Mb/s Show Sample Output


    1
    RX1=`cat /sys/class/net/${INTERFACE}/statistics/rx_bytes` (see script below)
    jp · 2012-01-23 18:22:44 10
  • Need to query hundreds of hosts with an ssh command ? Of course you'll have setup keys on all your remote HOSTs. But in the case a key is not present this command will skip that node, proceeding on to the next. -t: Force pseudo-tty allocation. This can be used to execute arbitrary screen-based programs on a remote machine. Also prevents unwanted stty messages being sent to console -q: Quiet mode. -o "BatchMode yes" If set to yes, passphrase/password querying will be disabled. This option is useful in scripts and other batch jobs where no user is present Show Sample Output


    1
    ssh -tq -o "BatchMode yes" $HOST <some_command> >> to_a_file
    jp · 2011-03-02 20:33:59 3

What's this?

commandlinefu.com 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

sync svn working copy and remote repository (auto adding new files)
Lists the local files that are not present in the remote repository (lines beginning with ?) and add them.

Rename files in batch

bypass any aliases and functions for the command
A simple directive which disables all aliases and functions for the command immediately following it. Shortcut for the bash built-in 'command' - "command linefoo". Think, {sic}...

GRUB2: set Super Mario as startup tune
I'll let Slayer handle that. Raining Blood for your pleasure.

Auto-log commands
A quick alias I use right before logging into a server so that I have a log of the transactions as well as the ability to re-connect from another computer. Useful for when your boss says "what commands did you run again on that server?" and you had already closed the terminal ;) I wrapped it in a script now, with more features, but this is the heart of it. Never leave home without it.

Update Ogg Vorbis file comments
The "vorbiscomment" utility lets you update information such as artist names and song and album tags in an Ogg Vorbis file. You can use this command to fix any mistakes that were made when ripping an album.

Extract the MBR ID of a device
Useful when you want to know the mbrid of a device - for the purpose of making it bootable. Certain hybridiso distros, for eg the OpenSUSE live ISO uses the mbrid to find the live media. Use this command to find out the mbrid of your USB drive and then edit the /grub/mbrid file to match it.

Quick glance at who's been using your system recently
This command takes the output of the 'last' command, removes empty lines, gets just the first field ($USERNAME), sort the $USERNAMES in reverse order and then gives a summary count of unique matches.

Get AWS temporary credentials ready to export based on a MFA virtual appliance
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token. This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use: `awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'` You must adapt the command line to include: * $MFA_IDis ARN of the virtual MFA or serial number of the physical one * TTL for the credentials

Set executable permissions on a file under Subversion
This avoids the "chmod +x filename" after performing a check out or export. From http://snipplr.com/view/5277/set-executable-permissions-on-a-file-under-subversion/


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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

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: