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:
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.
M is size in megabytes, man expac to see other sizes
%m is install size
%k is download size
This will list all installed packages on a RedHat/CentOS based system, sort them alphabetically, Parse off the version numbers, and delete any duplicate entries.
This is good if you need to build out a mirrored system or rebuild a failing system.
Uses line-porcelain in git blame, which makes it easier to parse the output.
Watch out if you have several USB drives plugged in: it scans the whole /media/ folder !!! You can replace /media/ by the path of a specific USB drive (something like /media/F77A-530B/)
I use a sound recorder and I want to plug the recorder and grab the most recent sound.
That's what this command does.
Use mv instead of cp to move instead of copy.
Change *.wav to the required file type.
Shows sorted by query time, the headers of mysqlbinlog entries. Then is easy to locate the heavier events on the raw log dump
Sometimes you want to see all of the systcls for a given $thing. I happened to need to easily look at all of the vm sysctls between two boxes and compare them. This is what I came up with.
See the summary.
This doesn't require any non-standard programs.
for those without the tree command.
Per country GET report, based on access log. Easy to transform to unique IP
tree -ifsF --noreport .|sort -n -k2|grep -v '/$'
(rows presenting directory names become hidden)
couldn't stand previous unsortability of at jobs list
The listing will be nice separated with dashes in chunks of identical files.
Size Inode Mode Count_of_identical_files UID GID Date Time Path/Filename
Simpler and without all of the coloring gimmicks. This just returns a list of branches with the most recent first. This should be useful for cleaning your remotes.
find -printf "%f\n" prints just the file name from the given path. This means directory paths which contain extensions will not be considered.