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:
Probably only works with GNU du and modern perls.
The value for the sort command's -k argument is the column in the CSV file to sort on. In this example, it sorts on the second column. You must use some form of the sort command in order for uniq to work properly.
I think I could cut down the number of pipes here, any suggestions?
This assumes your mail log is /var/log/mail.log
Useful to check DDoS attacks on servers.
This command takes the output of the 'last' command, removes empty lines, gets just the first field ($USERNAME), sort the $USERNAMES in reverse order and then gives a summary count of unique matches.
Sees if two records differ in their entries, irrespective of order.
For quick validation of folder's file-contents (structure not taken into account) - I use it mostly to check if two folders' contents are the same.
This command does a tally of concurrent active connections from single IPs and prints out those IPs that have the most active concurrent connections. VERY useful in determining the source of a DoS or DDoS attack.
Useful to detect which process is causing system loads. It shows process PID so as we can take further actions.
Very useful for finding the largest files and subdirectories at any given point. Any user can run it from current location just when need to know their largest files and subtdirectories from a certain point down as well.
This will tell you who has the most Apache connections by IP (replace IPHERE with the actual IP you wish to check). Or if you wish, remove | grep -c IPHERE for the full list.
List top 20 IP from which TCP connection is in SYN_RECV state.
Useful on web servers to detect a syn flood attack.
Replace SYN_ with ESTA to find established connections
usefull in case of abuser/DoS attacks.
find -printf '%u\n' | sort | uniq #just users
find -printf '%g\n' | sort | uniq #just groups