commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
This command is much quicker than the alternative of "sort | uniq -c | sort -n".
I use this to generate a playlist with all the podcasts I listen to.
Ordered from most recent to older.
The pipe to head removes the listing of . as the largest directory.
This command checks for the number of times when someone has tried to login to your server and failed. If there are a lot, then that user is being targeted on your system and you might want to make sure that user either has remote logins disabled, or has a strong password, or both. If your output has an "invalid" line, it is a summary of all logins from users that don't exist on your system.
Very useful when you need disk space. It calculates the disk usage of all files and dirs (descending them) located at the current directory (including hidden ones). Then sort puts them in order.
Sort a list of IPV4 addresses in numerical order. Great as a filter, or within vim using !}
Often, when sorting you want the sort to ignore extraneous characters. The b, d, and f tell sort to ignore leading blanks, use 'dictionary order' (ignore punctuation), and ignore (fold) case. Add a "u" if you only want one copy of duplicate lines.
This is a great command to use within vim to sort lines of text, using !}sort -bdf
I use this on debian testing, works like the other sorted du variants, but i like small numbers and suffixes :)
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.