What's this?

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/

Get involved!

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.

Universal configuration monitoring and system of record for IT.

Stay in the loop…

Follow the Tweets.

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.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

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:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags





All commands from sorted by
Terminal - All commands - 12,232 results
svn status | grep '^\?' | sed -e 's/^\?//g' | xargs svn add
2009-02-28 03:00:28
User: dollyaswin
Functions: grep sed xargs

These part of the command:

svn status | grep '^\?' => find new file or directory on working copy

sed -e 's/^\?//g' => remove "^" character on the first character of file name

xargs svn add => add file to subversion repository

You can modify above command to other circumtances, like revert addition files or commit files that have been modified. ^_^

e2label /dev/vg0/lv0 MyFiles
v=/dev/vg0/lv0; lvextend -L+200G $v && resize2fs $v
2009-02-28 02:30:49
User: wwest4
Functions: resize2fs

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)

pkill -n firefox
2009-02-28 01:19:59
User: Williebee

Kills the most recently created firefox process.

aptitude show $PROGRAM | grep Vers
2009-02-27 23:24:37
User: aabilio
Functions: grep

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.

sudo dd if=/dev/sda of=/media/disk/backup/sda.backup
2009-02-27 20:23:37
User: bandit36
Functions: dd sudo
Tags: backup dd

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 user@ssh.server.com dd of=~/backup/sda.backup
rsync -vazuK --exclude "*.mp3" --exclude "*.svn*" * user@host:/path
2009-02-27 19:58:02
User: sudopeople
Functions: rsync
Tags: svn exclude

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:



write user anytext
ifconfig | awk '/inet / {print $2}'
2009-02-27 17:05:08
User: haivu
Functions: awk ifconfig

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:


xmodmap -e "remove Lock = Caps_Lock"
2009-02-27 16:44:22
User: mzandrew

a quick one-line way to disable caps lock while running X.

vim -p file1 file2 ...
2009-02-27 16:43:59
User: haivu
Functions: vim
Tags: vim

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'

ls -1 | while read a; do mv "$a" `echo $a | sed -e 's/\ /\./g'`; done
grep "FOUND" /var/log/squidclamav.log | awk '{print $5"-"$2"-"$3","$4","$11}' | sed -e 's/\,http.*url=/\,/g' | sed -e 's/&/\,/g' | sed -e 's/source=//g' |sed -e 's/user=//g' | sed -e 's/virus=//g' | sed -e 's/stream\:+//g' | sed -e 's/\+FOUND//g'
2009-02-27 13:28:18
User: nablas
Functions: awk grep sed

This command will list a CSV list of infected files detected by clamav through squidclamav redirector.

awk 'BEGIN {FS=","} {loc = $4, val=$5; getline < "f0001ch1.csv"; print loc,val,$5}' f0001ch2.csv > data
2009-02-27 13:01:16
User: Masse
Functions: awk

Parses tektronic given csv files for both channel 1 and channel 2 and joins them together. Can be easily used by gnuplot after that.

rpm -qif `which more`
2009-02-27 08:59:07
User: alcik
Functions: rpm
Tags: rpm which

Replace 'more' command with any command which is in your PATH.

ls -ld **/*(/)
ls -ld *(/)
git commit --amend
2009-02-27 04:42:44
Tags: git

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.

alias trash="rm -fr ~/.local/share/Trash"
2009-02-27 01:55:30
Functions: alias

Force empties the user trash

dpkg-reconfigure -phigh xserver-xorg
git rm $(git ls-files --deleted)
2009-02-26 21:21:02
Functions: rm
Tags: git

This command handles git rm'ing files that you've deleted.

$ cat /etc/*-release
ls -l | grep ^d
2009-02-26 20:28:10
User: sysadmn
Functions: grep ls

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 -nt . -k 1,1 -k 2,2 -k 3,3 -k 4,4
2009-02-26 20:22:57
User: sysadmn
Functions: sort

Sort a list of IPV4 addresses in numerical order. Great as a filter, or within vim using !}

git diff --cached