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:
you can change the size :)
Display the size (human reading) of all the directories in your home path (~).
This one-liner is for cron jobs that need to provide some basic information about a filesystem and the time it takes to complete the operation. You can swap out the di command for df or du if that's your thing. The |& redirections the stderr and stdout to the mail command.
How to configure the variables.
FSCKDEV=`grep $TOFSCK /proc/mounts | cut -f1 -d" "`
MAILSUB="weekly file system check $TOFSCK "
This deals nicely with filenames containing special characters and can deal with more files than can fit on a commandline. It also avoids spawning du.
This command shows the size of directories below here, refreshing every 2s.
It will also track directories created after running the command (that what the find bit does).
The original didn't use -print0 which fails on weird file names eg with spaces.
The original parsed the output of 'ls -l' which is always a bad idea.
The command gives size of all files smaller than 1024k, this information, together with disk usage, can help determin file system parameter (e.g. block size) or storage device (e.g. SSD v.s. HDD).
Note if you use awk instead of "cut| dc", you easily breach maximum allowed number of records in awk.
On a Gentoo system, this command will tell you which packets you have installed and sort them by how much space they consume. Good for finding out space-hogs when tidying up disk space.
This will create a 10 MB file named testfile.txt. Change the count parameter to change the size of the file.
As one commenter pointed out, yes /dev/random can be used, but the content doesn't matter if you just need a file of a specific size for testing purposes, which is why I used /dev/zero. The file size is what matters, not the content. It's 10 MB either way. "Random" just referred to "any file - content not specific"
Useful to know, especially if you are dealing with output configurations in block size.
Tested on 'Red Hat'.
This command list and sort files by size and in reverse order, the reverse order is very helpful when you have a very long list and wish to have the biggest files at the bottom so you don't have scrool up.
The file size info is in human readable output, so ex. 1K..234M...3G
Tested with Linux (Red Hat Enterprise Edition)
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.