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 networking from sorted by
Terminal - Commands tagged networking - 29 results
showip() { nmcli connection show $1|grep ipv4.addresses|awk '{print $2}' ; }
2015-05-13 16:24:28
User: nnsense
Functions: awk grep

Sometimes it's useful to output just the ip address. Or some other information, changing the "ipv4.addresses" in command. The power of awk! Show all possible "greps" with

nmcli connection show [yourInterfaceNameHere]
ethtool -S eth0 | egrep "(drop|disc|err|fifo|buf|fail|miss|OOB|fcs|full|frags|hdr|tso).*: [^0]"
2014-07-15 05:27:34
User: suprjami
Functions: egrep

A grep against ethtool to look for common errors and packet loss statistics which network drivers report in their private data, which is queried with ethool -S. This is the current grep used in xsos (https://github.com/ryran/xsos), which I originally contributed and has been improved by the community over time.

watch -n1 iptables -vnL
watch -n1 iptables -vnL
wakeonlan 00:00:DE:AD:BE:EF
2014-06-13 16:16:33
User: tyzbit

Wakes up a computer on your LAN with a Wake-On-LAN packet. MAC Address must match the NIC MAC, computer must have WOL enabled in the BIOS.

nmap --iflist
watch "lsof -i -P |grep ESTABLISHED |awk '{printf \"%15.15s \\t%s\\n\", \$1, \$9}'"
2013-04-03 02:04:11
User: skarfacegc
Functions: watch

Shows which applications are making connections, and the addresses they're connecting to. Refreshes every 2 seconds (watch's default). Test on OSX, should work anywhere watch and lsof work.

nc -l <port-number>
2013-03-20 15:25:57
User: cybertoast

Simple way to test if a port is available to the public. Run this command on the "server" and run a `telnet host-ip port-number` on the client. Test by sending strings to the server, which will be displayed in the server terminal.

/sbin/ifenslave -c bond0 eth1
2013-02-06 16:04:35
User: tduvally

This forces a bonded interface to switch to another slave in the bond as its active slave.

telnet 0 <port>
2012-11-16 03:38:49
User: somaddict
Functions: telnet

Super fast way to ftp/telnet/netcat/ssh/ping your loopback address for testing. The default route is simply reduced to 0.

ifconfig eth0 allmulti
2012-05-25 16:43:41
User: SEJeff
Functions: ifconfig

Disabling an interface's multicast filter is like disabling IGMP snooping on a switch. It is useful for testing and troubleshooting.

tcpdump -w - |pv -bert >/dev/null
2011-12-14 00:24:02
User: h3xx
Functions: tcpdump

Real gurus don't need fancy tools like iftop or jnettop.

nmap -v -sT
2011-11-19 07:06:52
User: Dhinesh

TCP Connect scanning for localhost and network

lsof -Pi | grep LISTEN
2011-10-03 12:50:18
User: 5partan
Functions: grep

This option is much faster, as it checks only network nodes.

lsof -i
2011-10-03 02:06:30
User: shsingh

This option selects the listing of all Internet and x.25 (HP-UX) network files.

netstat -plntu
netstat -plnt
2011-09-30 19:56:32
User: DopeGhoti
Functions: netstat

While `lsof` will work, why not use the tool designed explicitly for this job?

(If not run as root, you will only see the names of PID you own)

lsof -Pn | grep LISTEN
netstat -tulpnc
2011-04-20 07:30:31
User: altern
Functions: netstat

shows opened ports on machine in continuous mode (refreshing every 10 sec)

curl -s http://standards.ieee.org/regauth/oui/oui.txt | grep $1
ping -I eth0 www.yahoo.com
2010-04-12 06:25:07
User: octopus
Functions: ping

This command only check the network connection from given eth. This is very useful if you are using more then one interface in your server or laptop.

python -c "import platform; print platform.node()"
tcpdump -i any -n tcp[13] == 2
ifconfig eth1 | grep inet\ addr | awk '{print $2}' | cut -d: -f2 | sed s/^/eth1:\ /g
2009-11-03 19:26:40
User: TuxOtaku
Functions: awk cut grep ifconfig sed

Sometimes, you don't really care about all the other information that ifconfig spits at you (however useful it may otherwise be). You just want an IP. This strips out all the crap and gives you exactly what you want.