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:
Generates the list of clients (IPs addresses) that have used the Squid webproxy according to the most recent log. Every IP appears only once in the list.
This probably only works without modifications in RHEL/CentOS/Fedora.
This command will find the highest context switches on a server and give you the process listing.
The command will make it easy to determine free IP ranges in a crowded sub-net.
Need admin right to run dpkg-query
Get link to external sites of a url
This sorts files in multiple directories by their modification date. Note that sorting is done at the end using "sort", instead of using the "-ltr" options to "ls". This ensures correct results when sorting a large number of files, in which case "find" will call "ls" multiple times.
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.
This command give a human readable result without messing up the sorting.
The following displays only the entries that are duplicates.
Uniq command is mostly used in combination with sort command, as
uniq removes duplicates only from a sorted file. i.e In order for uniq to
work, all the duplicate entries should be in the adjacent lines.
ls -al gives all files, sort +4n sorts by 5th field numerically
Sort using kth column using : delimiter
I had the problem that our monitoring showed that the "/" filesystem is >90% full. This command helped me to find out fast which subdirs are the biggest. The system has many NFS-mounts therefore the -x.
cut -f1,2 - IP range 16
cut -f1,2,3 - IP range 24
cut -f1,2,3,4 - IP range 24
"nl -ba" numbers all lines in the file (including empty lines), "sort -nr"
sorts the lines in descending order, and the "cut" command finally removes
the line numbers again.
here's a version which works on OS X.