All commands (14,187)

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

Expand shortened URLs
curl(1) is more portable than wget(1) across Unices, so here is an alternative doing the same thing with greater portability. This shell function uses curl(1) to show what site a shortened URL is pointing to, even if there are many nested shortened URLs. This is a great way to test whether or not the shortened URL is sending you to a malicious site, or somewhere nasty that you don't want to visit. The sample output is from: $ expandurl http://t.co/LDWqmtDM

uniq without pre-sorting
Reads stdin, and outputs each line only once - without sorting ahead of time. This does use more memory than your system's sort utility.

Set all CPU cores' CPU frequency scaling governor to maximum performance

Sum columns from CSV column $COL

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"

Monitor memory fine-grained usage (e.g. firefox)
Sometimes top/htop don't give the fine-grained detail on memory usage you might need. Sum up the exact memory types you want

Remote copy directories and files through an SSH tunnel host
If you have lots of remote hosts sitting "behind" an ssh proxy host, then there is a special-case use of "rsynch" that allows one to easily copy directories and files across the ssh proxy host, without having to do two explicit copies: the '-e' option allows for a replacement "rsh" command. We use this option to specify an "ssh" tunnel command, with the '-A' option that causes authentication agent requests to be forwarded back to the local host. If you have ssh set up correctly, the above command can be done without any passwords being entered.

Upload folder to imageshack.us (forum)
Each file in the current folder is uploaded to imageshack.us If the folder contains other filetypes change: $for files in * to: $for files in *.jpg (to upload ONLY .jpg files) Additionally you can try (results may vary): $for files in *.jpg *.png The output URL is encased with BB image tags for use in a forum.

Combine cssh and shell expansion to execute commands on a large cluster
This will open an awful lot of little windows, but is quite useful if you want to quickly patch something on a cluster of servers.

Download streaming video in mms
require mimms package


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: