commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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.
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:
This one has a better performance, as it is a one pass count with awk. For this script it might not matter, but for others it is a good optiomization.
make usable on OSX with filenames containing spaces. note: will still break if filenames contain newlines... possible, but who does that?!
Enhanced version: fixes sorting by human readable numbers, and filters out non MB or GB entries that have a G or an M in their name.
Uses the formatting of a man page to show an outline of its headers and sub-headers.
This was tested on Ubuntu 12.04 (Precise) LTS Server. It returns the name of the symlink within /dev/disk/by-id for the physical drive you specify. Change /dev/sda to the one you want, and replace ata- with scsi- or the appropriate type for your drive.
I used this to pre-configure grub-pc during a non-interactive install because I had to tell it which disk to install grub on, and physical disks don't have a UUID such as that blkid provides.
Not always does Xorg run on :0. For times like those, this script allows you to find out which it is.
find files recursively from the current directory, and list the extensions of files uniquely
looks at html for "ip" (it's a CSS class), then a little of cut and egrep to get IPv4 address.
I use this oneliner into conky.
Use meaningful exit codes
change "source" to "cat" to view output instead of assigning
Get link to external sites of a url
Depending on your Apache access log configuration you may have to change the sum+=$11 to previous or next awk token.
Beware, usually in access log last token is time of response in microseconds, penultimate token is size of response in bytes. You may use this command line to calculate sum and average of responses sizes.
You can also refine the egrep regexp to match specific HTTP requests.
Get a list of all the unique hostnames from the apache configuration files. Handy to see what sites are running on a server. When i saw the command i had some ideas to make it shorter. Here is my version.
Simple TCPDUMP grepping for common unsafe protocols (HTTP, POP3, SMTP, FTP)
First get a api key for google url shortner from here https://developers.google.com/url-shortener/
Then replace the API_KEY in the command
Very useful for finding all the source code that should be compiled.