Commands by meathive (10)

  • This command clones an image three times and creates a 'tile' image that can be used for a repeating pattern wallpaper. Add 'rm $f $of $off' to the end for cleanup (command was too long to submit with it). See this link for an example:

    goWall() { if [ $# -ne 1 ]; then echo 'goWall image';return;fi;w=w.jpg;o="$1";f="$1"-f;of="$1"-af;off="$1"-aff;convert "$1" -flop $f;montage -geometry +0+0 -tile 2x "$1" $f $of;convert $of -flip $off;montage -geometry +0+0 -tile 1x $of $off $w }
    meathive · 2012-07-17 05:01:58 0
  • sudo /sbin/ifconfig | gotxt2imgmail

    gotxt2imgmail() { if [ $# != 1 ]; then echo 'gotxt2imgmail < email >'; return; fi; e="$1"; f=$RANDOM.png; convert label:@- $f; echo "" | mailx -s $f -a $f $e }
    meathive · 2011-08-24 12:05:05 0
  • This command, or a derivative like it, is a must-have if you're a server administrator interested in website optimization: Command requires Yahoo's YUI, find it here: Show Sample Output

    gominify() { if [ $# -ne 2 ]; then echo 'gominify < src > < dst >'; return; fi; s="$1"; d="$2"; java -jar yui.jar $s >$d; if [ $? == 0 ]; then a=$( ls -sh $s | awk '{print $1}' ); b=$( ls -sh $d | awk '{print $1}' ); echo "Saved $s ($a) to $d ($b)"; fi;}
    meathive · 2010-08-03 10:19:24 0
  • My variation on an audio burning command from commandlinefu - this one doesn't crap out if you want to burn a CD in a directory whose permissions don't allow it, and instead rips everything to /tmp. If you mount your music partition like I do using Samba, you probably don't have write permission inside that file system in order to create the temporary directory other audio burning commands here use. Not a bad idea to add cdrom to your groups, and /bin/eject with visudo.

    goburncd() { d=/tmp/goburncd_$RANDOM; mkdir $d && for i in *.[Mm][Pp]3; do lame --decode "$i" "$d/${i%%.*}.wav"; done; sudo cdrecord -pad $d/* && rm -r $d; eject }
    meathive · 2010-07-06 21:58:10 0
  • This command will format your alias or function to a single line, trimming duplicate white space and newlines and inserting delimiter semi-colons, so it continues to work on a single line. Show Sample Output

    goclf() { type "$1" | sed '1d' | tr -d "\n" | tr -s '[:space:]'; echo }
    meathive · 2010-06-26 21:44:17 0
  • This command will automate the creation of ESSIDs and batch processing in pyrit. Give it a list of WPA/WPA2 access points you're targeting and it'll import those ESSIDs and pre-compute the potential password hashes for you, assuming you've got a list of passwords already imported using: pyrit -i dictionary import_passwords Once the command finishes, point pyrit to your packet capture containing a handshake with the attack_db module. Game over. Show Sample Output

    gopyrit () { if [ $# -lt 1 ]; then echo $0 '< list of ESSIDs >'; return -1; fi; for i in "$@"; do pyrit -e $i create_essid && pyrit batch; done; pyrit eval }
    meathive · 2010-06-19 01:11:00 0
  • A shortcut to generate documentation with phpdoc. Defaults to HTML; optionally to PDF if third argument is given. Stores documentation in cwd under ./docs/. I forget the syntax to the output, -o, option, so this is easier.

    gophpdoc() { if [ $# -lt 2 ]; then echo $0 '< file > < title > [ pdf ]'; return; fi; if [ "$3" == 'pdf' ]; then ot=PDF:default:default; else ot=HTML:frames:earthli; fi; phpdoc -o $ot -f "$1" -t docs -ti "$2" }
    meathive · 2010-06-09 01:15:04 0
  • newly downloaded videos goyoutube random goyoutube rand This command assumes you've already downloaded some YouTube .mp4 or .flv video files via other means. Requires 'shuf', or your own stdin shuffler.

    goyoutube() { d=/path/to/videos p=$d/playlist m=$d/*.mp4 f=$d/*.flv if [ "$1" == 'rand' ]; then ls -1 $m $f | shuf >$p else ls -1t $m $f >$p fi mplayer -geometry 500x400 -playlist $p }
    meathive · 2010-04-11 18:53:49 0
  • gorecord foo.mp4 I've tried all of the screen recorders available for Linux and this is easily the best. xvidcap segfaults; VNC is too much hassle. There are alternatives of this command already here that I am just too lazy to reply to. Messing with the frames per second option, -r, 25 seems to be the best. Any lower and the video will look like a flipbook, if it records at all - -r 10 won't - any faster is the same, oddly enough. Edit: CLF doesn't like my long command to add audio, so here it is in the description. goaddaudio() { if [ $# != 3 ]; then echo 'goaddaudio < audio > < src video > < dst video >' return fi f=goaddaudio$RANDOM ffmpeg -i "$2" &> $f d=$( grep Duration $f | awk '{print $2}' | tr -d ',' ) && rm $f && ffmpeg -i "$1" -i "$2" -r 25 -ab 192k -ar 44100 -sameq -t $d "$3" }

    gorecord() { if [ $# != 1 ]; then echo 'gorecord video.mp4' return fi ffmpeg -f x11grab -s <resolution> -r 25 -i :0.0 -sameq -vcodec mpeg4 "$1" }
    meathive · 2010-03-29 20:21:35 1
  • See if you are unclear about the Google Analytics cookie system. If Firefox is your daily browser, be a good Orwellian and run this command regularly. If you see, 'SQL error near line 1: database is locked', close Firefox and run again.

    gofuckanalytics() { echo "DELETE FROM moz_cookies WHERE name LIKE '__utm%';" | sqlite3 $( find ~/.mozilla -name cookies.sqlite ) }
    meathive · 2010-03-07 09:16:14 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

Install pip with Proxy
Installs pip packages defining a proxy

Sort a one-per-line list of email address, weeding out duplicates

Make changes in .bashrc immediately available

Remove a file whose name begins with a dash ( - ) character
Using the redundant ./ directory information prevents the dash from occurring at the beginning of the filename, and being interpreted as an option of the rm command. Also works using: $ rm -- -filename

parted - scripted partitioning (of all multipathed SAN LUNs)
`multipath -ll` requires Device Mapper multipath.conf configuration. And of course, replace "3PARdata,VV" with your disk array's SCSI vendor,LUN name. - GPT partition table allows you to create >2TB partitions

Insert a comment on command line for reminder
Comments can be used directly on the command line so I can save in the history a brief description of what command does.

How to trim a video using ffmpeg
Will trim the video to 4 seconds starting from the beginning. The -vcodec , -acodec options are required so that ffmpeg knows in what video/audio format you want for the new video.

port scan using parallel
It takes over 5 seconds to scan a single port on a single host using nmap $ time (nmap -p 80 &> /dev/null) real 0m5.109s user 0m0.102s sys 0m0.004s It took netcat about 2.5 minutes to scan port 80 on the class C $ time (for NUM in {1..255} ; do nc -w 1 -z -v 192.168.1.${NUM} 80 ; done &> /dev/null) real 2m28.651s user 0m0.136s sys 0m0.341s Using parallel, I am able to scan port 80 on the entire class C in under 2 seconds $ time (seq 1 255 | parallel -j255 'nc -w 1 -z -v 192.168.1.{} 80' &> /dev/null) real 0m1.957s user 0m0.457s sys 0m0.994s

List the URLs of tabs of the frontmost Chrome window in OS X
This also works with Safari if you just change the application name. Replace $ window 1 with $ windows to list the URLs of tabs in all windows instead of only the frontmost window. This also includes titles: $ osascript -e{'set o to""','tell app"google chrome"','repeat with t in tabs of window 1','set o to o&url of t&"\n"&" "&title of t&"\n"',end,end}|sed \$d .

Convert all .wav to .mp3
Audio convert is a script that uses zenity and lame to transcode virtually any format to any other format provided you have the libraries installed to do so.

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: