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/id_rsa.pub|ssh 5z474n@mainframe.nl 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.


    1
    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 8
  • Beeps on mouse's every move. Bear in mind that, at least on Ubuntu, /dev/input/mice can be read only by root.


    4
    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 22
  • Infinitely plays beeps with sinusoidally changing sound frequency. Ideal for alarm on an event.


    1
    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 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

Fast command-line directory browsing
After typing cd directory [enter] ls [enter] so many times, I figured I'd try to make it into a function. I was surprised how smoothly I was able to integrate it into my work on the command line. Just use cdls as you would cd. It will automatically list the directory contents after you cd into the directory. To make the command always available, add it to your .bashrc file. Not quite monumental, but still pretty convenient.

Detect illegal access to kernel space, potentially useful for Meltdown detection
Based on capsule8 agent examples, not rigorously tested

List only the directories
-d: list directory entries instead of contents, and do not dereference symbolic links

Convert JSON to YAML
Convert JSON to YAML. Note that you'll need to have PyYaml installed.

Fix VirtualBox error

Find usb device in realtime
Using this command you can track a moment when usb device was attached.

Execute a command with a timeout
A timeout is great, but what if the command is taking longer than expected because it's hung up or ran into some other problem? That's where the -k option comes in. Run "some_command" and timeout after 30s. If the command is still running after 1 minute, it will receive a kill signal.

grep -v with multiple patterns.
You can use -e to pass multiple patterns.

Copy data using gtar
It copies the entire current working directory to the destination directory with compression enabled.

list block devices
Shows all block devices in a tree with descruptions of what they are.


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: