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.

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.

UpGuard checks and validates configurations for every major OS, network device, and cloud provider.

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:



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!

Top Tags



Commands tagged dns from sorted by
Terminal - Commands tagged dns - 31 results
NSPR_LOG_MODULES=nsHostResolver:5 NSPR_LOG_FILE=/tmp/log.txt /Applications/Firefox.app/Contents/MacOS/firefox
NSPR_LOG_MODULES=nsHostResolver:5 NSPR_LOG_FILE=/tmp/log.txt firefox
dnstop -l 3 enp1s0f0
host `hostname` | rev | cut -d' ' f1 | rev
2014-10-01 18:55:05
Functions: cut host rev

Gives the DNS listed IP for the host you're on... or replace `hostname` with any other host

dig +short which.opendns.com txt @
2014-02-09 19:24:33
User: dinorox
Functions: dig
Tags: dig dns

It's somewhat common ISPs to intercept DNS queries at port 53 and resolve them at their own.

To check if your ISP is intercepting your DNS queries just type this command in the terminal.

"#.abc" it's an OK answer.

But if you get something like "I am not an OpenDNS resolver.", yep, you are beign cheated by your ISP.

for i in `ip addr show dev eth1 | grep inet | awk '{print $2}' | cut -d/ -f1`; do echo -n $i; echo -en '\t'; host $i | awk '{print $5}'; done
dig +short -x <ip-address>
dscacheutil ?flushcache
wki () { dig +short txt "${*// /_}".wp.dg.cx | sed -e 's/^"\(.*\)"$/\1/' -e 's/\([^\]\)"[^\]*"/\1/g' -e 's/\\\(.\)/\1/g' }
2012-05-30 11:36:25
User: kovirobi
Functions: sed

This removes the enclosing quotation marks ("), and sticthes the different packets together, e.g. '

dig +noall +answer exsample.com
kill -SIGHUP `cat /var/run/mydns.pid`
2011-10-21 14:29:24
User: ironmarc
Functions: kill

Occasionally, to force zone updating, cache flush is necessary. This command is better than restart the mydns daemon.

rndc flush
2011-10-21 14:27:05
User: ironmarc
Functions: rndc

Occasionally, to force zone updating, cache flush is necessary. The use of this command is better than restart the Bind9 process.

domain=google.com; for ns in $(whois $domain | awk -F: '/Name Server/{print $2}'); do echo ">>> Nameservers for $domain from $a <<<"; dig @$ns $domain ns +short; echo; done;
2011-05-08 04:46:34
User: laebshade
Functions: awk dig echo whois

Change the $domain variable to whichever domain you wish to query.

Works with the majority of whois info; for some that won't, you may have to compromise:

domain=google.com; for a in $(whois $domain | grep "Domain servers in listed order:" --after 3 | grep -v "Domain servers in listed order:"); do echo ">>> Nameservers for $domain from $a

Note that this doesn't work as well as the first one; if they have more than 3 nameservers, it won't hit them all.

As the summary states, this can be useful for making sure the whois nameservers for a domain match the nameserver records (NS records) from the nameservers themselves.

mwiki () { dig +short txt `echo $*|sed 's| *|_|g'`.wp.dg.cx; }
dig +trace google.com
2010-09-03 18:57:29
User: duxklr
Functions: dig
Tags: dig dns

Simple command to trace a DNS query from the root all the way to the authoritative servers.

nslookup -q=txt <topic>.wp.dg.cx
dig +short NS org.
curl icanhazip.com
dig +short myip.opendns.com @resolver1.opendns.com
2010-04-02 21:53:26
User: dooblem
Functions: dig

Instead of opening your browser, googling "whatismyip"...

Also useful for scripts.

dig can be found in the dnsutils package.

mwiki() { dig +short txt "$*".wp.dg.cx; }
sed -i 's/20[0-1][0-9]\{7\}/'`date +%Y%m%d%I`'/g' *.db
2010-03-24 07:28:58
User: alf
Functions: sed

Will edit *.db files in the same directory with todays date. Useful for doing a mass update to domains on a nameserver, adding spf records, etc.

Looks for a string starting with 200 or 201 followed by 7 numbers, and replaces with todays date. This won't overwrite Ip's but i would still do some double checking after running this.

Make sure your server's date is correct, otherwise insert your own serial number.

rndc reload

should usually follow this command.

mwiki () { blah=`echo $@ | sed -e 's/ /_/g'`; dig +short txt $blah.wp.dg.cx; }
dig +short myip.opendns.com @resolver1.opendns.com
nslookup {ip}
dig +short -x {ip}
2009-12-21 14:43:35
User: putnamhill
Functions: dig
Tags: IP reverse dig dns

The +short option should make dig less chatty.