Commands by 5z474n (3)

  • If you frequently need to connect to your ubersecure mainframe from various uberunsafe machines, you have to face difficult decision: (a) type the password everytime during the session (lame), (b) add local public key to mainframes authorized_keys file (unsafe), (c) as above, but remove this key at the end of the session (pain in the a55). So let's say you save The Command to tempauth file in bin directory of your mainframe's account and make it executable. Then, while you're on one of these unsafe ones, do: cat $HOME/.ssh/|ssh bin/tempauth 30 and password prompts stop the harassment for 30 minutes and you don't have to care to remove the unsafe key after that.

    Keys=$HOME/.ssh/authorized_keys;Back=$Keys.tmp.bak;Time=${1:-15};cp $Keys $Back;cat /dev/stdin >>$Keys;echo mv $Back $Keys|at now+${Time}minutes;
    5z474n · 2009-07-15 23:45:02 0
  • Beeps on mouse's every move. Bear in mind that, at least on Ubuntu, /dev/input/mice can be read only by root.

    while true; do beep -l66 -f`head -c2 /dev/input/mice|hexdump -d|awk 'NR==1{print $2%10000}'`; done
    5z474n · 2009-07-11 12:01:27 1
  • Infinitely plays beeps with sinusoidally changing sound frequency. Ideal for alarm on an event.

    tempo=33; slope=10; maxfreq=888; function sinus { echo "s($1/$slope)*$maxfreq"|bc -l|tr -d '-'; }; for((i=1;;i++)); do beep -l$tempo -f`sinus $i`; done
    5z474n · 2009-07-10 21:24:11 0

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

Prevent an IPv6 address on an interface from being used as source address of packets.
If two or more IPv6 addresses are assigned to an interface, apply this command to all but the address that you want to use as the source address of outbound packets. This is Linux-specific and requires the iproute package, or equivalent for your distribution.

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

Write comments to your history.
A null operation with the name 'comment', allowing comments to be written to HISTFILE. Prepending '#' to a command will *not* write the command to the history file, although it will be available for the current session, thus '#' is not useful for keeping track of comments past the current session.

Dump audio from video without re-encoding.
This removes the video and subsequent file size and directly copies the audio.

Find the package that installed a command

show current directory
Opens a file or URL in the user's preferred application.

Exclude inserting a table from a sql import
Starting with a large MySQL dump file (*.sql) remove any lines that have inserts for the specified table. Sometimes one or two tables are very large and uneeded, eg. log tables. To exclude multiple tables you can get fancy with sed, or just run the command again on subsequently generated files.

combine `mkdir foo && cd foo` into a single function `mcd foo`
I find that I create a directory and then cd into that directory quite often. I found this little function on the internets somewhere and thought I'd share it. Just copy-paste it into you ~/.bash_profile and then `source ~/.bash_profile`.

enable all bash completions in gentoo

find an unused unprivileged TCP port
Some commands (such as netcat) have a port option but how can you know which ports are unused?

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: