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,997 results
watch --interval 1 ls -lah
2013-10-16 10:41:15
User: c0r3dump3d
Functions: ls watch
-1

Use this command if you want to control the size of the files in human readable, every one second.

sed 's/^[ \t]*//' < <file> > <file>.out; mv <file>.out <file>
pkill -9 -u username php5-fcgi
2011-08-09 22:14:21
User: hpavc
-1

Similar commands, same origin.

pgrep [-cflvx] [-d delimiter] [-n|-o] [-P ppid,...] [-g pgrp,...] [-s sid,...] [-u euid,...] [-U uid,...] [-G gid,...] [-t term,...] [pattern]

pkill [-signal] [-fvx] [-n|-o] [-P ppid,...] [-g pgrp,...] [-s sid,...] [-u euid,...] [-U uid,...] [-G gid,...] [-t term,...] [pattern]

sudo chown -R nobody:admin /Applications/XAMPP/xamppfiles/htdocs/
sed G
2009-05-02 12:11:40
Functions: sed
-1

G option cause a file to be spacing line by line.

awk 'BEGIN{dir=DIR?DIR:ENVIRON["PWD"];l=split(dir,parts,"/");last="";for(i=1;i<l+1;i++){d=last"/"parts[i];gsub("//","/",d);system("ls -ld \""d"\"");last=d}}'
2009-10-22 16:28:07
User: arcege
Functions: awk
-1

Handled all within awk. Takes the value from $PWD and constructs directory structures and runs commands against them. The gsub() call is not necessary, but added for better visibility.

If a variable DIR is given on the awk command-line, then that directory is used instead:

awk -vDIR=$HOME/.ssh 'BEGIN{dir=DIR?...}'
cat /proc/meminfo
cd $(ls -ltr|grep ^d|head -1|sed 's:.*\ ::g'|tail -1)
2011-08-10 03:39:35
Functions: cd grep head ls sed tail
-1

Replace the head -1 with head -n that is the n-th item you want to go to.

Replace the head with tail, go to the last dir you listed.

You also can change the parameters of ls.

find -type f | xargs ls -1tr
$ssh-copy-id ptaduri@c3pusas1
sudo urlsnarf -i wlan0
ssh-keygen ptaduri@c3pusas1
parallel -a <(seq 0 20) mkdir /tmp/dir1/{}
echo lowercaseword | tr '[a-z]' '[A-Z]'
rename s/ .php/ .html/ *.html
hashalot -s salt -x sha256 <<<"test"
2010-11-30 19:32:29
User: vayn
Tags: hash
-1

It's inspired by Generate MD5 hash for a string() [ http://goo.gl/ObCrl ], you need to install hashalot(very small) first. Salt is not necessary.

There is an optional command:

sha256 -s salt -x <<<"test"
mtr google.com
2012-02-19 22:27:48
User: d_voge
-1

You need to have mtr installed on your host.

alias mplayer='mplayer -stop-xscreensaver'
host google.com|awk '{print $NF}'
ggdG
cat /dev/sda | pv -r > /dev/null
2011-01-23 22:58:56
User: kerim
Functions: cat
-1

Change your drive letter as you wish.

Using pv command for speed detect.First of all you must install pv command for usage.

http://www.bayner.com/

kerim@bayner.com

find . -type f -iname '*.java.orig' -delete
find . -printf "%T@ %p\n" | sed -e 1d | while read ts fn; do ts=${ts%.*}; if [ $ts -ge ${gts:-0} ]; then gts=$ts; echo `date -d @$gts` $fn; fi; done
:%s/^V^M//g
2009-08-19 11:59:22
User: slim
-1

Whereas ^V is CTRL-V.

converts a dos file to unix by removing 0x13 characters