Hide

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.

Hide

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:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

All commands from sorted by
Terminal - All commands - 11,847 results
plink lyu0@mysshserver -pw 123456
Place a filename at the beginning of the line to make it easier to edit the search at the end of the command.
echo SSBMb3ZlIFlvdQo= | base64 -d
sed -e 's/ *$//' ~/.bash_history | sort | uniq -cd | sort -nr | head
Use history -S in your .logout file
2009-02-07 10:53:14
User: vijucat
-1

That's the key part.

I got this from http://www.macosxhints.com/article.php?story=20070715091413640. See that article for other other, more basic, tcsh-specific history-related settings.

find ~ -name '*.sqlite' -exec sqlite3 '{}' 'VACUUM;' \;
2009-02-07 10:45:41
User: ggyy_sun
Functions: find
24

Compress information DBs of firefox to speed up the launch of browser.

sqlite3 ~/.liferea_1.4/liferea.db 'VACUUM;'
2009-02-07 10:40:02
User: ggyy_sun
1

If you use liferea frequently, you will see obvious speedup after you executed this command.

kill -HUP ` ps -aef | grep -i firefox | sort -k 2 -r | sed 1d | awk ' { print $2 } ' `
apt-cache search someregex
2009-02-07 09:15:19
User: chrisdrew
Functions: apt
0

Search the names and descriptions of all available packages and prints out the name and the short description.

xmms2 addpls cdda://
mount | grep : | tr -s ' ' -d 3 | xargs umount -v
# cut -d ' ' -f1 /var/log/nginx/nginx-access.log | sort | uniq -c | sort -nr | head -10 | nl
formail -Y -s /usr/sbin/sendmail bar@example.com < /var/mail/foo
convert -resize 200 -sharpen 40 some_file.pdf[0] some_file.jpg
2009-02-06 23:12:01
User: abcde
5

convert is included in ImageMagick. Don't forget the [X] (where X is the page number). [0] is the first page of the PDF.

date --date="1 fortnight ago"
2009-02-06 20:57:59
User: mkc
Functions: date
3

The date command does offset calculations nicely, handles concepts like "a month" as you'd expect, and is good for offsets of at least 100M years in either direction.

view `ls -1 access_log.* | tail -n 1`
2009-02-06 18:38:25
User: jimjmarion
Functions: tail
0

This command opens the latest, most current rotating apache access log for visual analysis and inspection. Run this command from the apache log directory. For error logs, replace access_log with error_log.

apt-show-versions -u
2009-02-06 17:56:13
User: cowholio4
Functions: apt
-3

apt-show-versions is a program that shows what packages in the system may be updated and several useful information. The -u option displays a list of upgradeable packages:

From: http://www.debian.org/doc/manuals/apt-howto/ch-helpers.en.html

dd if=/dev/sdX of=/root/sdX.bin bs=1M count=1
2009-02-06 17:45:59
User: dhing
Functions: dd
-4

This will copy the first 1MB of your /dev/sdX volume to your /root/sdX.bin file, where SDX is the name of the device you wish to copy the data from (Usually a hard disk)

NOTE: Make sure you capitalize the M in field for BS.

git svn --authors-file=some-authors-file clone svn://address/of/svn/repo new-git-dir
git diff HEAD..rev | git apply --index; git commit
2009-02-06 17:29:46
User: Pistos
Functions: diff
4

Use this to make a new commit that "softly" reverts a branch to some commit (i.e. squashes the history into an inverse patch). You can review the changes first by doing the diff alone.

convert -resize 50%x50% image{,_resize}.jpg
git daemon --reuseaddr --verbose --export-all --base-path=/parent/of/bare/git/repos
2009-02-06 17:25:04
User: Pistos
0

Use this to start git daemon serving all git repos under a path.

tail -f <filename> | grep -C <# of lines to show above and below> <text>
alias scd='dirs -v; echo -n "select number: "; read newdir; cd -"$newdir"'
cflow file.c | grep ':$' | sed 's/ <.*//'