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
byobu new-session -d -s name; byobu new-window -t name:1 -n 'window-1-title' 'command-1'; byobu new-window -t name:2 -n 'window-2-title' 'command-2'; byobu select-window -t name:1; byobu -2 attach-session -t name
2013-01-09 14:09:26
User: alikhalil
0

Create a byobu (tmux) session and attach several windows to it.

curl --silent http://www.census.gov/population/international/ | grep wclocknum | sed -r 's@^.*>([0-9,]+)<.*$@\1@'
2013-07-15 22:35:05
User: malathion
Functions: grep sed
Tags: curl
0

Deprecated due to a change in the site design: see alternatives.

wget -q -O- http://example-podcast-feed.com/rss | grep -o "<enclosure[ -~][^>]*" | grep -o "http://[ -~][^\"]*" | xargs wget -c
2013-09-24 12:38:08
User: talha131
Functions: grep wget xargs
0

This script can be used to download enclosed files from a RSS feed. For example, it can be used to download mp3 files from a podcasts RSS feed.

Add-MailboxPermission -Identity "username_of_mailbox_owner" -User username_control_to -AccessRights Fullaccess -InheritanceType all
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
cat /etc/named.conf | grep -Po '(?<=(named/)).*(?=\.db)'
2014-10-25 20:16:17
User: KonKar
Functions: cat grep
0

Allows you to have a list of the domains on the server.

for f in *.rar;do unrar e ?$f?;done
while true; do clear; nmap ${hostname} -PN -p ${hostport}; sleep 5; done
2009-08-14 20:19:59
User: flokra
Functions: sleep
0

the command for the impatient sysadmin: simply checks every five secs, if a host or a specific service running on it is up. ideal for hosts that are configured not to respond on pings.

tcpdump -w "$(sed 's/-//gi; s/ /_/gi'<<<"-vvv -s0 -ieth1 -c10 icmp").pcap"
tcpdump -nr capture.file | awk '{print }' | grep -oE '[0-9]{1,}.[0-9]{1,}.[0-9]{1,}.[0-9]{1,}' | sort | uniq -c | sort -n
2011-06-16 19:27:11
User: shahabv
Functions: awk grep sort tcpdump uniq
Tags: tcpdump
0

We can get useful statistics from tcpdump with this simple command.

Thanks "Babak Farrokhi" to teaching me this ;)

who am i | wc -l
od -An -N6 -tx1 /dev/urandom | sed -e 's/^ *//' -e 's/ */:/g' -e 's/:$//' -e 's/^\(.\)[13579bdf]/\10/'
2012-08-31 13:15:03
User: outly3r
Functions: od sed
0

- The last sed expression ensures the unicast/multicast bit is set to zero

- The greedy space replacements are for portability across UNIX seds (note there's TWO spaces and not just one, as this web shows, in s/^ */)

star -c -v -f myarchive.tar -no-dirslash list=list.txt
eval `ls -1d * | awk '{print "zip -r "$1".zip "$1";"}'`
synclient TapButton1=1 TapButton2=2 TapButton3=3
2013-07-16 03:37:21
User: m33600
0

Knoppix is Debian running in RAM, one of the best distros I've seen, but I had to left click the hardware button to use the system, because touchpad ignored taps. Not anymore

Add-ADPermission "username_mailbox" -User "Domain\User" -Extendedrights "Send As"
macdst="5873b856445f";macsrc="d2a791e1715a";pkt="d4c3b2a1020004000000000000000000ffff000001000000e3eab353fa1f 0b007400000074000000$macdst $macsrc 0842ffffffffffff";for i in {1..16}; do pkt="$pkt $macdst"; done; echo "$pkt" | xxd -r -p > magicpacket.pcap
2014-07-02 17:37:44
Functions: echo
0

just set macdst to the mac address of the system

you wish to wake up, the macsrc is optional but helps

use tcpreplay to broadcast or wireshark to view

echo $(wget http://ipecho.net/plain -q -O -)
2014-10-25 20:25:05
User: KonKar
Functions: echo wget
0

Easiest way to get the external IP address.

tail -f FILE | grep --color=always KEYWORD
grep xxxx messages | cut -d ' ' -f 1,2,3
2010-10-22 00:01:00
User: sumudu
Functions: cut grep
0

first greps syslog for certain events (grep xxxx messages) then displays the 1st 2nd and 3rd fields (-f 1,2,3) seperated by space(-d ' ')

whois -H $(cat ./list_of_domains) | awk 'BEGIN{RS=""}/Registrant/,/Registration Service Provider:/ {print} END{print "----------------\n"}'
2011-01-11 12:55:34
User: djsmiley2k
Functions: awk cat whois
0

Nice neat feedback showing contact infomation for as many domains as you wish to feed it. I used a list of domains, each one on a new line as supplied by our registar, as we needed to check they were all upto date and back them up as we are updating them all.

while :; do OLD=$NEW; NEW=`cat /proc/net/dev | grep eth0 | tr -s ' ' | cut -d' ' -f "3 11"`; echo $NEW $OLD | awk '{printf("\rin: % 9.2g\t\tout: % 9.2g", ($1-$3)/1024, ($2-$4)/1024)}'; sleep 1; done
a=$(xwininfo |gawk 'BEGIN {FS="[x+ \t]*"} /-geometry/ {print int(($3+1)/2)*2"x"int(($4+1)/2)*2"+"$5"+"$6}') ; echo ${a} ; ffmpeg -f x11grab -s ${a} -r 10 -i :0.0 -sameq -f mp4 -s wvga -y /tmp/out.mpg
2012-08-31 14:48:41
User: dwygo
Functions: echo gawk
0

Now we can capture only a specific window (we have to chose by clicking on it)

ffmpeg complains about "Frame size must be a multiple of 2" so we calculate the upper even number with (g)awk trickery.

We remove the grep, we are already using (g)awk here ....why losing time with grep !!! ;)

pv /dev/random > /dev/null
2013-01-09 15:47:07
User: vdo
Tags: pv entropy
0

Meters your actual entropy with pipe viewer command

.load ./path/to/file.js