Commands by pdurbin (1)

  • "Vice versa xorriso is able to copy file objects out of ISO 9660 filesystems." -- Show Sample Output

    xorriso -osirrox on -indev /tmp/pmagic-6.7.iso -report_about NOTE -extract / /tmp/extractedfiles
    pdurbin · 2012-05-26 10:48:59 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

Install pip with Proxy
Installs pip packages defining a proxy

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

Convert JSON to YAML
Requires installing json2yaml via npm: npm install -g json2yaml (can also pipe from stdin) Ref:

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"

Re-emerge all ebuilds with missing files (Gentoo Linux)
This loops through all installed ebuilds and checks if every file that should be installed is still there and if not adds it to emerge. It includes a verbose output to stderr too. If you have packages installed that have whitespace in their filenames you have to change the IFS to "newline".

Perl one-liner to determine number of days since the Unix epoch
There are some environments that use this value for password and account expiration. It's helpful to be able to quickly determine the number of days since the Unix epoch (dse) when working directly with the configuration files as an administrator.

Retrieve a random command from the API
Seeing that we get back plain text anyway we don't need lynx. Also the sed-part removes the credit line.

Downmix from stereo to mono and play radio stream with mplayer
The solution to a year long (and extremely frustrating) problem I've had, caused by the fact that I only have one speaker; this command downmixes the stream to monophonic output, making sure I don't miss any of the music. NOTE: When stream is in .m3u format, a -playlist option is required, as shown below: $ mplayer -af pan=1:0.5:0.5 -channels 1 -playlist radiostream.m3u This command works great with aliases for various channels in .bashrc. Sample below: $ alias radio1='mplayer -af pan=1:0.5:0.5 -channels 1 radio1stream.pls'

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Redirect incoming traffic to SSH, from a port of your choosing
Stuck behind a restrictive firewall at work, but really jonesing to putty home to your linux box for some colossal cave? Goodness knows I was...but the firewall at work blocked all outbound connections except for ports 80 and 443. (Those were wide open for outbound connections.) So now I putty over port 443 and have my linux box redirect it to port 22 (the SSH port) before it routes it internally. So, my specific command would be: $iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 22 Note that I use -A to append this command to the end of the chain. You could replace that with -I to insert it at the beginning (or at a specific rulenum). My linux box is running slackware, with a kernel from circa 2001. Hopefully the mechanics of iptables haven't changed since then. The command is untested under any other distros or less outdated kernels. Of course, the command should be easy enough to adapt to whatever service on your linux box you're trying to reach by changing the numbers (and possibly changing tcp to udp, or whatever). Between putty and psftp, however, I'm good to go for hours of time-killing.

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: