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,144 results
gst-launch-0.10 autovideosrc ! video/x-raw-yuv,framerate=\(fraction\)30/1,width=640,height=480 ! ffmpegcolorspace ! autovideosink
2009-09-16 06:31:23
User: jcollado
2

Open a window that displays camera capture.

Framerate, width and height may be changed to match your needs.

ps -u<user>
ls -t | awk 'NR>5 {system("rm \"" $0 "\"")}'
2009-09-16 04:58:08
User: haivu
Functions: awk ls
Tags: awk ls
-2

I have a directory containing log files. This command delete all but the 5 latest logs. Here is how it works:

* The ls -t command list all files with the latest ones at the top

* The awk's expression means: for those lines greater than 5, delete.

mate - `find . -name 'filename'`
budir=/tmp/bu.$$;for name in repMainPath/*/format;do dir=${name%/format};bufil=dumpPath/${dir##*/};svnadmin hotcopy --clean-logs $dir $budir;svnadmin dump --delta $budir>$bufil;rm -rf $budir;done
2009-09-16 01:34:48
User: arcege
Functions: dump
Tags: bash svn
2

Use of hotcopy for safety/stability of the backups.

git add -u
2009-09-16 00:13:14
User: donnoman
Tags: git
48

It deletes all removed files, updates what was modified, and adds new files.

wget http://twitter.com/help/test.json -q -O -
2009-09-15 23:22:26
User: ninadsp
Functions: wget
3

Returns a JSON object, by connecting to the 'test' endpoint of the Twitter API. Simplest way to check if you can connect to Twitter. Output also available in XML, use '/help/test.xml' for that

find repMainPath -maxdepth 1 -mindepth 1 -type d | while read dir; do echo processing $dir; sudo svnadmin dump --deltas $dir >dumpPath/`basename $dir`; done
2009-09-15 20:14:51
User: Marco
Functions: dump echo find read sudo
Tags: bash svn
2

This command dumps all SVN repositories inside of folder "repMainPath" (not recursively) to the folder "dumpPath", where one dump file will be created for each SVN repository.

(some_command 2>&1 1>&3 | tee /path/to/errorlog ) 3>&1 1>&2 | tee /path/to/stdoutlog
mencoder tv:// -tv driver=v4l2:width=800:height=600:device=/dev/video0:fps=30:outfmt=yuy2:forceaudio:alsa:adevice=hw.2,0 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1800 -ffourcc xvid -oac mp3lame -lameopts cbr=128 -o output.avi
2009-09-15 19:46:06
User: ivalladt
6

Record audio to MP3 stream and video to MPEG-4 stream from webcam to AVI file using mencoder. Gives floating point exception in some mencoder versions.

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/