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:
Live extension of an ext3 file system on logical volume $v by 200GB without the need to unmount/remount.
Requires that you have 1) a version of resize2fs that contains code merged from ext2online, and 2) kernel support for online resizing. (e.g. RHEL 5)
Kills the most recently created firefox process.
Output: Version 3.2-0 (for example if you type # aptitude show bash | grep Vers
Depends on the language of your distribution, because the name of the word "Version" in other languages may be different.
This will create an exact duplicate image of your hard drive that you can then restore by simply reversing the "if" & "of" locations.
sudo dd if=/media/disk/backup/sda.backup of=/dev/sda
Alternatively, you can use an SSH connection to do your backups:
dd if=/dev/sda | ssh firstname.lastname@example.org dd of=~/backup/sda.backup
rsyncs files to a server excluding listed files
also a file can be used to exclude common exclude rules and/or to exclude a ton of files, like so:
rsync --exclude-from '~/.scripts/exclude.txt'
where exclude.txt has one rule per line:
On the Mac, the format ifconfig puts out is little different from Linux: the IP address is space separated, instead of colon. That makes parsing the IP address easier. See releated command for Linux/Unix:
a quick one-line way to disable caps lock while running X.
Edit the files, each in a separate tab. use gT and gt to move to the left- and right-tab, respectively. to add another tab while editing, type ':tabe filename'
This command will list a CSV list of infected files detected by clamav through squidclamav redirector.
Parses tektronic given csv files for both channel 1 and channel 2 and joins them together. Can be easily used by gnuplot after that.
Replace 'more' command with any command which is in your PATH.
It's pretty common to forgot to commit a files, be it a modification, or a brand new file.
If you did forget something, git add the files you want, and then git commit --amend. It will essentially redo the last commit, with the changes you just added. It seeds the commit message with the last commit message by default.
You probably shouldn't do this if you've already pushed the commit.
Force empties the user trash
This command handles git rm'ing files that you've deleted.
Show only the subdirectories in the current directory. In the example above, /lib has 135 files and directories. With this command, the 9 dirs jump out.
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