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:
With this command, you can check the difference between the volumes mounted and the volume in /etc/fstab.
..not guaranteed to always be accurate but fun to see how old you Linux installation is based on the root partitions file system creation date.
Find out the earliest installation time of a linux system by getting the / filesystem creation time. This example is only valid the os is installed on an ext2/3/4 filesystem.
Just the commands for the lvreduce I keep forgetting.
-P uses the POSIX output format, which makes information on each file system always printed on exactly one line. "column -t" makes a table from the input.
Show disk space info, grepping out the uninteresting ones beginning with ^none while we're at it.
The main point of this submission is the way it maintains the header row with the command grouping, by removing it from the pipeline before it gets fed into the sort command. (I'm surprised sort doesn't have an option to skip a header row, actually..)
It took me a while to work out how to do this, I thought of it as I was drifting off to sleep last night!
Shorter way to find the device for a given mountpoint
Identical output but a different way without having to shoot with the Awk cannon :)
No need for grep | awk. -P on df will force the mount point to be on the same line as the device
most usefull when creating batch scripts using several usb drives and some commands like mkntfs needs a device name
the -w option for grep is here to filter lines when you have multiple drives with the same volume label. Without this option, the grep command will return
tune2fs also provides the same information . But the information does not give the current usage , it gives the information when the file system was last mounted.
You can use this one-liner for a quick and dirty (more customizable) alternative to the watch command. The keys to making this work: everything exists in an infinite loop; the loop starts with a clear; the loop ends with a sleep. Enter whatever you'd like to keep an eye on in the middle.
Reports all local partitions having more than 90% usage.
Just add it in a crontab and you'll get a mail when a disk is full.
(sending mail to the root user must work for that)
Exclude 400 client hosts with NFS auto-mounted home directories.
Easily modified for inclusion in your scripts.
For disk space constraint testing. Leaves a little space available for creating temp files, etc. Easily free up the used disk space again by deleting the dummy00 file. Can tailor the testing by building smaller 'blocks' to suit the needs of the testing.
WARNING: do not do this to the '/' (root) filesystem unless you know what you are doing... on some systems it could crash the OS.
put it in crontab to get an alert when / is over 89% utilization.