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

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

Top Tags

Hide

Functions

All commands from sorted by
Terminal - All commands - 12,060 results
xe vm-list
2010-09-28 18:22:03
User: layer8
-1

Citrix XenServer 5.6, can be piped to grep for more interesting output

lsof -Pnl +M -i6 | grep 8080
ps -eo args,%cpu | grep -m1 PROCESS | tr 'a-z-' ' ' | awk '{print $1}'
echo $((1+2+3+4))
2>/dev/null dd if=/dev/urandom bs=1 count=6 | od -t x1 |sed '2d;s/^0\+ //;s/ /:/g'
find /path/to/dir -type f -exec grep \-H "search term" {} \;
2009-01-26 16:32:14
User: root
Functions: find grep
-1

Simple use of find and grep to recursively search a directory for files that contain a certain term.

xe vm-copy vm="ABCServer" sr-uuid=24565487-accf-55ed-54da54993ade784a new-name-label="Copy of ABCServer" new-name-description="New Description"
sudo apt-get remove $(dpkg -l|awk '/^ii linux-image-/{print $2}'|sed 's/linux-image-//'|awk -v v=`uname -r` 'v>$0'|sed 's/-generic//'|awk '{printf("linux-headers-%s\nlinux-headers-%s-generic\nlinux-image-%s-generic\n",$0,$0,$0)}')
2012-04-02 10:53:40
User: mtron
Functions: awk sed sudo
-1

small update for this command to work with linux kernels 3.x

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
cat large.xml | xclip
2009-07-08 16:30:07
User: copremesis
Functions: cat
-1

avoid mouse abuse and the constant struggle of balancing scroll velocity ... not to mention that burning sensation in your upper right shoulder ....

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"