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

convert a web page into a pdf
This uses the "command-line print" plugin for Firefox (http://torisugari.googlepages.com/commandlineprint2). This same plugin can also produce PNGs. On *nix, the file must exist; therefore the touch bit in front. Also, firefox seems to ignore saved user preferences when "printing" this way (margins, header, footer, etc.), so I had to tweak my ~/.mozilla/firefox/xxxxxxxx.default/prefs.js file by hand. Yup, that's *prefs.js* not user.js - apparently, firefox ignores my user.js file too...

Oneliner to run commands on multiple servers
Oneliner to run commands on multiple servers over ssh. - First parameter "$1" is the command you want to execute remotely. ( It can be multiple commands e.g. "hostname;uptime") - Second parameter "${@:2}" represents the remote host/s you want to run the command/s on.

Find all files larger than 500M and less than 1GB

move messages directly from one IMAP inbox to another
This one-liner was useful in helping someone I know to get off of MS Exchange. `mailutil` proved to be a much better alternative than `fetchmail` or `getmail` in this case. It quickly moved all mails to the destination server (a simple Dovecot/Maildir setup), with no need to convert back and forth between mbox/maildir on the user's own system.

c_rehash replacement
When you don't have c_rehash handy. Really simple - if you have a .pem file that doesn't really contain a x509 cert (let's say, newreq.pem), it will create a link, simply called '.0', pointing to that file.

Generate random valid mac addresses
Shorter and more straightforward. Also in perl: $ perl -e 'print join(":", map { sprintf "%0.2X",rand(256) }(1..6))."\n"'

Runs previous command but replacing
Really useful for when you have a typo in a previous command. Also, arguments default to empty so if you accidentally run: $ echo "no typozs" you can correct it with $ ^z

Get your outgoing IP address
should be very consistent cause it's google :-)

List all groups and the user names that were in each group
"cut" the user names from /etc/passwd and then running a loop over them.

Use Vim to convert text to HTML.
``vimhtml somefile.txt`` will open vim for the HTML convertion and close it immediately after its done, leaving you with somefile.html which you can later use in your website or whatever.


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: