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,487 results
convert -bordercolor Transparent -border 1x1 in.png out.png
2009-02-15 19:42:17
User: jimmac
-1

Requires either imagemagick or graphicsmagic utility.

find . -maxdepth 1 -iname '*jpg' -exec convert -quality 60 {} lowQ/{} \;
2009-02-15 19:34:38
User: abhinay
Functions: find
-1

* lowQ/ is the output directory

* pass quality level from 1 to 100

du -hs * | grep '^[0-9,]*[MG]' | sort -rn
mencoder "${file}" -of rawaudio -oac mp3lame -ovc copy -o audio/"${file/%avi/mp3}"
2009-02-15 14:57:54
User: fulat2k
5

This commands saves the output in the audio directory. The portion ${file/%avi/mp3} uses bash string replacement to replace the avi to mp3 within the ${file} variable.

useradd -s /sbin/nologin nicdev
eudcedit
2009-02-15 14:47:37
User: Williebee
-7

Create unique characters (up to 6400) used in the font library.

clgrep keyword
explorer /select,[file]
find "$DIR" -regex "$FILENAME" -type f -print0 | xargs -0 sed -i _`date "+%y%m%d%H%M%S"` -E "s/$TEXT1/$TEXT2/g"
netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | sed s/::ffff:// | cut -d: -f1 | sort | uniq -c | sort -n
exim -bp | exiqsumm -c
2009-02-15 09:10:50
User: dt
1

statistics are sorted based on number of recipients.

convert panorama_rainbow_2005.jpg -resize 40% panorama_rainbow_compress.jpg
2009-02-15 08:24:50
User: pcardout
0

convert -resize 750?500 -quality 80% *.jpg

These are command-line invocations of ImageMagick functions. The first sizes an image file to 40% of original and saves it to a different name, while the second makes all jpg files in a directory sized to 750x500 pixels. Such a pleasure not to need to point and click to make a bunch of thumbnails -- for example.

perfmon.msc
2009-02-15 05:27:57
User: Williebee
-7

Starts the Performance Monitor console that monitors the system load. It will help to observe and test the system or parts of the system and also help to find any problems.

for x in *.pgp do `cat /file_with_the_passphrase.dat|(gpg --batch --no-tty --yes --passphrase-fd=0 --decrypt `basename $x`; ) > 'dump_content.dat'` done;
cat -n $file | tail -n 100 && head -n number-of-lines-you-want-to-keep > newfile
2009-02-15 01:02:10
User: bbelt16ag
Functions: cat head tail
-1

tells you the number of lines in said file, and then tail the last 100 lines ( or how many are messed up) then u take the total amount of lines and then subract the 100 or so lines u DONT WANT, then do a head -n $new_number and then redirect it to new file.db

doskey l=dir /OD $*
2009-02-15 00:29:23
User: VonC
-7

doskey is the Windows cmd.exe equivalent of the Unix alias. '$*' means 'all parameters'

This example is like alias l='ls -alrt': it will display files from oldest to newest, for one or more directories.

doskey /MACROS list macros defined for cmd.exe, like 'alias' list aliases defined for the current Unix shell.

cd \
2009-02-14 21:53:51
User: VonC
Functions: cd
-32

Useful to quickly get back to the Windows root directory of the current drive from a sub-directory within that drive.

Works also without space between 'cd' and backslash: 'cd\' or 'cd \' have the same effect

driverquery /si /fo table
2009-02-14 18:54:15
User: Williebee
1

Show device drivers and their properties, including digital signatures /si and in table format /fo.

cat welcome | wall
2009-02-14 18:12:50
User: Williebee
Functions: cat
-3

Show message in file "welcome" to all logged in terminal users.

touch <filename>
> filename
alias rk='d=$(dcop|grep $PPID) && s=$(dcop $d konsole currentSession) && dcop $d $s renameSession'
2009-02-14 00:02:43
User: wwest4
Functions: alias
1

usage: renam

in a script you must replace $PPID with $(awk '{print $4}' /prod/$PPID/stat)

git config --global alias.log1 "log --pretty=oneline --abbrev-commit"
2009-02-13 23:38:42
User: bartman
0

This command limits the oputut of git log to one-line per commit and an abbreviated commit ID.

find -printf '%u %g\n' | sort | uniq
2009-02-13 22:42:49
User: leper421
Functions: find sort
8

find -printf '%u\n' | sort | uniq #just users

find -printf '%g\n' | sort | uniq #just groups

PS1='$PWD$ '
2009-02-13 22:00:57
User: Aldiansblog
-2

If you have tried to change your prompt and made a mistake, use this command to retrieve a standard prompt.

If you used the export command when you changed your prompt, also use it there:

export PS1='$PWD$ '