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,951 results
nmap 192.168.0-1.0-255 -sP
2009-03-23 22:19:05
4

Depending on the network setup, you may not get the hostname.

find ./ -mtime -5 | xargs rm -f
curl -Is slashdot.org | egrep '^X-(F|B|L)' | cut -d \- -f 2
fuser -nu tcp 3691
lsof -P | grep ':3000'
cp --parents /source/file /target-dir
2009-03-23 18:35:15
User: bitmage
Functions: cp
6

The --parents option will cause cp or mkdir to automatically create the parent directory structure.

mkdir --parents /one/two/three/dir

will create /one, /one/two, and /one/two/three as needed before creating dir. cp will copy files with their full directory structure into the target directory with this option.

Thanks to Peter Leung at:

http://linuxcommando.blogspot.com/2007/11/use-of-parents-flag-in-mkdir-and-c.html

which has good examples of usage.

kill -9 `ps -u <username> -o "pid="`
kill -9 $(pidof process)
CTRL + e
CTRL + a
for i in `find . | grep jar$`; do echo $i; jar tvf $i | grep 'search-string'; done;
ps aux | grep 'httpd ' | awk {'print $2'} | xargs kill -9
convert -colors 256 -resize 16x16 face.jpg face.ppm && ppmtowinicon -output favicon.ico face.ppm
2009-03-23 15:00:13
User: medina
Tags: ImageMagick
14

Create a favicon suitable for use on your web site. Note: ppmtowinicon is part of libpbm, not ImageMagick.

for f in *.mp3 ; do lame --mp3input -b 128 "$f" ./resamp/"$f" ; done
2009-03-23 14:39:14
User: jjclarkson
Tags: audio
4

This will lower the quality of mp3 files, but is necessary to play them on some mobile devices.

ffmpeg -i file.flv -r 15 -b 128k -s qcif -acodec amr_nb -ar 8000 -ac 1 -ab 13 -f 3gp -y out.3gp
2009-03-23 14:30:45
User: jjclarkson
Tags: video ffmpeg
5

Download YouTube videos as .flv and convert them to .3gp for your mobile phone.

find . -name *.php | xargs grep -i -n 'TERM'
convert -colorspace gray face.jpg gray_face.jpg
2009-03-23 14:18:04
User: medina
Tags: ImageMagick
4

Use ImageMagick to create a "black and white" copy of an image.

addfunction () { declare -f $1 >> ~/.bashrc ; }
2009-03-23 12:55:04
User: dagh
Tags: bash
6

Example: To store the function addfunction after you have defined it:

addfunction addfunction
alias mux='clear && cd ~/Music/ && ls && echo -n "File> " && read msi && mplayer ~/Music/$msi'
2009-03-23 10:45:27
User: Noxn
Functions: alias cd echo ls read
-2

An alias i made for myself to play music in a faster way.

Works great when you have Guake / Tilda installed (Console that drops down like in the game QUAKE)

---

I put this in my bash_alias file (I'm on ubuntu, the bash_alias file does autostart with the right config) but it works putting it in bashrc too. Or anything that autostarts when the console is opened.

---

Needs Mplayer and music files to work. With out music theres nothing to play!

Oh, and also, without modification, this alias will try to play stuff from your ~/Music folder! (case sensitive). Make sure that folder exists and has music OR edit this alias to fit your needs.

for x in *.ogg; do ffmpeg -i "$x" "`basename "$x" .ogg`.mp3"
mencoder -ovc copy -oac copy -of avi -o remuxed.avi original.avi
2009-03-23 10:15:36
User: iain
6

When playback of AVI files (containing a video format like XviD or DivX) is stuttering, it in 90% of the files is caused by a poorly or wrongly interleaved file. The issue can be permanently resolved by RE-MUXING the AVI video-files that have this problem

vimdiff file{1,2}
2009-03-23 10:08:16
User: H4rpy
2

vim will open both files side by side and show colored diffs

gst-launch v4l2src
2009-03-23 05:45:00
User: samliu
-1

Cheese or other webcam software not working? Try this.

CTRL+u
cd