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

Commands tagged ip address from sorted by
Terminal - Commands tagged ip address - 105 results
ip -o -4 a s
2012-09-19 10:59:05
User: ioggstream
4

Short list of all ip.

Shows even the newly supported multiple ip address on the same interface (see eth1).

For ipv6 use -6

curl icanhazip.com
curl queip.tk/ip
lsof -p `pidof pidgin` | awk '{ print $9 }'|egrep `hostname` | grep -o ">[^:]\+:" | tr -d ":>" | while read line; do host $line; done;
dig o-o.myaddr.l.google.com @ns1.google.com txt +short
2012-07-30 06:54:57
User: quentin
Functions: dig
0

Asks Google what your current IP address is. Bonus: Remove "@ns1.google.com" and you will instead get the IP address of your DNS server.

hostname -I
2012-07-18 19:43:48
User: bashfan
Functions: hostname
Tags: awk IP ip address
0

That's the easiest way to do it. -I (or capital i) display all network addresses of a host

ifconfig | sed -n 's/.*inet addr:\([0-9.]\+\)\s.*/\1/p'
ip -f inet a | awk '/inet / { print $2 }'
2012-07-18 15:13:10
User: BorneBjoern
Functions: awk
Tags: awk IP ip address
3

gives u each configured IP in a seperate line.

nmap -T4 -sn 192.168.1.0/24
2012-06-19 17:07:24
User: drewbled
0

Does a ping scan on the local subnet and returns the IPs that are up

curl ifconfig.me/all
2012-05-16 18:22:28
User: pykler
9

Gets all kind of info, ifconfig.me rocks ...

for just the ip addess you can use ifconfig.me or ifconfig.me/ip

lynx -dump http://www.ip2location.com/ | sed -n '/^ *Field Name *Value *$/,/^ *\[_\] *Mobile .*Carrier.*name/p'
lynx -dump ip.nu
curl ip.nu
curl ifconfig.me
echo -n $(curl -Ss http://icanhazip.com) | xclip
2012-02-17 16:58:40
User: red_five
Functions: echo
0

Gets the IP and sticks it into the middle-mouse-click buffer

wget http://icanhazip.com -qO-
w3m mon-ip.com -dump|grep -Eo "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"|uniq|xclip -selection clipboard
wget ifconfig.me/ip -q -O -
curl icanhazip.com
cat /var/log/auth.log | grep -i "pam_unix(sshd:auth): authentication failure;" | cut -d' ' -f14,15 | cut -d= -f2 | sort | uniq
2011-10-25 04:58:09
User: JohnQUnknown
Functions: cat cut grep sort
0

This command shows a sorted list of the IP addresses from which there have been authentication errors via SSH (possible script kiddies trying to gain access to your server), it eliminates duplicates so it's easier to read, but you can remove the "uniq" command at the end, or even do a "uniq -c" to have a count of how many times each IP address shows in the log (the path to the log may vary from system to system)

wget -O - -q http://checkip.dyndns.org/ | cut -d':' -f2 | cut -d'<' -f1| cut -c2-
2011-09-17 13:42:01
User: ztank1013
Functions: cut wget
-2

This is just a "cut" addicted variant of the previous unixmonkey24730 command...

wget http://checkip.dyndns.org/ -q -O - | grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'
curl http://my-ip.cc/host.json
2011-09-01 00:31:49
User: samleb
0

JSON version.

Additionally it may give your geolocation if it's known by hostip.info

curl http://my-ip.cc/host.xml
2011-09-01 00:30:03
User: samleb
-1

XML version.

Additionally it may give your geolocation if it's known by hostip.info

curl http://my-ip.cc/host.txt
2011-09-01 00:28:49
User: samleb
-1

Additionally it may give your geolocation if it's known by hostip.info