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.

Universal configuration monitoring and system of record for IT.
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

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!
Hide

Top Tags

Hide

Functions

Hide

Credits

All commands from sorted by
Terminal - All commands - 12,134 results
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0:fps=30:outfmt=yuy2
2009-09-15 19:41:41
User: ivalladt
5

View webcam output using mplayer, with correct fps and outfmt settings according to my webcam model.

cat *.sql | mysql <db_name>
ffmpeg -f alsa -r 16000 -i hw:2,0 -f video4linux2 -s 800x600 -i /dev/video0 -r 30 -f avi -vcodec mpeg4 -vtag xvid -sameq -acodec libmp3lame -ab 96k output.avi
2009-09-15 17:03:25
User: ivalladt
5

Record from a webcam, audio using ALSA encoded as MP3, video as MPEG-4.

echo a,b,c | sed -e s/,/\',\'/g -e s/^/\(\'/ -e s/$/\'\)/
rm -rf [a-bd-zA-Z0-9]* c[b-zA-Z0-9]*
2009-09-15 14:22:56
User: arcege
Functions: rm
Tags: shell rm
1

Remove everything in current directory except files starting with "ca".

mencoder -of rawaudio -ovc copy -oac mp3lame -o output.mp3 input.avi
2009-09-15 11:28:01
User: ivalladt
3

Extracts an MP3 encoded audio stream from an input video file.

mencoder -ovc copy -audiofile input.mp3 -oac copy input.avi -o output.avi
2009-09-15 11:26:05
User: ivalladt
2

Creates a new video file with video stream copied from input file and a different audio stream

mencoder -ovc copy -nosound input.avi -o output.avi
2009-09-15 11:22:51
User: ivalladt
1

Remove sound from input video file, output video stream is copied from input video stream, with no audio.

perl -i -pe 's/\xef\xbb\xbf//g' <file>
tar cvfz dir_name.tgz dir/
2009-09-15 10:20:20
Functions: tar
Tags: tar
0

This command creates tar zip of a directory and its sub-directories.

echo {'1,2,3',4}" o'clock" ROCK
2009-09-15 10:12:49
User: danam
Functions: echo
5

AFAIR this is the wording ;)

export PS1='C:${PWD//\//\\\}>'
find -type f |while read a;do [ "`head -c3 -- "${a}"`" == $'\xef\xbb\xbf' ] && echo "Match: ${a}";done
find /home/dir -mtime +1 -print -exec gzip -9 {} \; -exec mv {}.gz {}_`date +%F`.gz \;
sudo tune2fs -m 1 /dev/sda4
2009-09-14 21:11:55
User: bassel
Functions: sudo tune2fs
2

According to tune2fs manual, reserved blocks are designed to keep your system from failing when you run out of space. Its reserves space for privileged processes such as daemons (like syslogd, for ex.) and other root level processes; also the reserved space can prevent the filesystem from fragmenting as it fills up. By default this is 5% regardless of the size of the partition.

http://www.ducea.com/2008/03/04/ext3-reserved-blocks-percentage/

hdparm -t /dev/sda
: ${VAR:?unset variable}
2009-09-14 19:41:01
User: arcege
Tags: shell
-1

Works in all shells. Does not require a test. Handles like an assertion.

cdrecord -v -blank=all -force
cdrecord -v path_to_iso_image.iso
display "$(wget -q http://dynamic.xkcd.com/comic/random/ -O - | grep -Po '(?<=")http://imgs.xkcd.com/comics/[^"]+(png|jpg)')"
2009-09-14 18:40:14
User: syssyphus
Tags: wget xkcd
6

i sorta stole this from

http://www.shell-fu.org/lister.php?id=878#MTC_form

but it didn't work, so here it is, fixed.

---

updated to work with jpegs, and to use a fancy positive look behind assertion.

[ -z "$VAR" ] && echo "VAR has not been set" && exit 1
echo {1..3}" o'clock" ROCK
echo "$(</etc/issue)"
2009-09-14 09:44:35
User: mobidyc
Functions: echo
-2

another replacement for cat.

type <filename>
2009-09-14 09:37:23
User: danam
Functions: type
4

Also searches for aliases and shell builtins

ffmpeg -ss 0:58:15 -i DavidLettermanBlackCrowes.mpg -acodec copy DavidLettermanBlackCrowes.ac3
2009-09-14 00:08:36
User: PLA
3

There are some pretty good live performances on late night TV. With Mythtv I record David Letterman, Jimmy Fallon, and Conan nightly all in HD from over the air broadcasts. If I find a live performance I like I copy it to my Rockboxed iPod using this command. The Rockbox firmware knows how to downmix 5.1 audio. The command above extracts the audio from the video starting at 58 minutes and 15 seconds. It ends at the end of the file since this was the last performance of the recording. The command creates an ac3 file. I copy the ac3 file to my Rockbox iPod and rock on.