Commands by alvinx (12)

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

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"

rsync directory tree including only files that match a certain find result.
'-mtime -10' syncs only files newer 10 days (-mtime is just one example, use whatever find expressions you need) printf %P: File's name with the name of the command line argument under which it was found removed. this way, you can use any src directory, no need to cd into your src directory first. using \\0 in printf and a corresponding --from0 in rsync ensures that even filenames with newline characters work (thanks syssyphus for #3808). both, #1481 and #3808 just work if you either copy the current directory (.) , or the filesystem root (/), otherwise the output from find and the source dir from rsync just don't match. #7685 works with an arbitrary source directory.

Duplicate several drives concurrently
If you have some drive imaging to do, you can boot into any liveCD and use a commodity machine. The drives will be written in parallel. To improve efficiency, specify a larger block size in dd: $dd if=/dev/sda bs=64k | tee >(dd of=/dev/sdb bs=64k) | dd of=/dev/sdc bs=64k To image more drives , insert them as additional arguments to tee: $dd if=/dev/sda | tee >(dd of=/dev/sdb) >(dd of=/dev/sdc) >(dd of=/dev/sdd) | dd of=/dev/sde

Terrorist threat level text
This line provides the same result by reading the output of a less arbitrary value. This is a personal choice on the matter, and the result on different machines may vary.

Install pip with Proxy
Installs pip packages defining a proxy

Get video information with ffmpeg
ffprobe is specially intended to get video information

Get information about a video file

extracts 64 bytes of random digits from random lines out of /dev/random sent to stdio
Use this the next time you need to come up with a reasonably random bitstring, like for a WPA/WPA2 PSK or something. Takes a continuous stream of bytes coming from /dev/urandom, runs it through od(1), picking a random field ($0 and $1 excluded) from a random line and then prints it.

Check to make sure the whois nameservers match the nameserver records from the nameservers themselves
Change the $domain variable to whichever domain you wish to query. Works with the majority of whois info; for some that won't, you may have to compromise:; for a in $(whois $domain | grep "Domain servers in listed order:" --after 3 | grep -v "Domain servers in listed order:"); do echo ">>> Nameservers for $domain from $a

live ssh network throughput test
connects to host via ssh and displays the live transfer speed, directing all transferred data to /dev/null needs pv installed Debian: 'apt-get install pv' Fedora: 'yum install pv' (may need the 'extras' repository enabled)

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: