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.

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

Tags

Hide

Functions

Commands tagged nmap from sorted by
Terminal - Commands tagged nmap - 14 results
nmap -sP 192.168.1.0/24
fping -ga 192.168.1.0/24 2> /dev/null
2014-01-31 19:19:19
User: netaxiz
Tags: nmap ping
2

Will report back IP address's of all hosts that are UP.

nmap -sn 192.168.1.0/24
nmap --iflist
nmap -sL 74.125.237.1/24
2012-05-30 00:51:20
User: the_wanderer
Tags: nmap
0

Nmap will list all IP's in the target specified, can specify subnet or range of IP addresses. It will attempt to resolve all IP's listed. No packets sent to target only generates DNS queries.

checkport() { sudo nmap -sS -p $1 $2 }
2011-12-13 11:46:15
Functions: sudo
Tags: nmap scan port
0

Check to see if a port is open or closed on a given host.

nmap -v -sT 192.168.0.0/24
2011-11-19 07:06:52
User: Dhinesh
1

TCP Connect scanning for localhost and network 192.168.0.0/24

nmap -sT -PN -vv <target ip>
2011-07-22 02:37:19
User: Richie086
0

Change the IP address from 127.0.0.1 to the target machines ip address. Even if the target has ICMP (ping) blocked, it will show you what ports are open on the target. Very handy for situations where you know the target is up and online but wont respond to pings.

nmap -oG - -T4 -p22 -v 192.168.0.254 | grep ssh
2011-01-11 16:12:23
User: SeeFor
Functions: grep
Tags: nmap grep
6

Using NMAP to check to see if port 22(SSH) is open on servers and network devices.

nmap -v -sP 192.168.0.0/16 10.0.0.0/8
2010-07-14 19:53:02
User: anapsix
6

nmap for windows and other platforms is available on developer's site: http://nmap.org/download.html

nmap is robust tool with many options and has various output modes - is the best (imho) tool out there..

from nmap 5.21 man page:

-oN/-oX/-oS/-oG : Output scan in normal, XML, s|

sudo nmap -F -O 192.168.1.1-255 | grep "Running: " > /tmp/os; echo "$(cat /tmp/os | grep Linux | wc -l) Linux device(s)"; echo "$(cat /tmp/os | grep Windows | wc -l) Window(s) devices"
2010-01-10 03:09:56
User: matthewbauer
Functions: echo grep sudo
3

Shows how many Windows and Linux devices are on your network.

May add support for others, but that's all that are on my network right now.

nmap -R -sL 209.85.229.99/27 | awk '{if($3=="not")print"("$2") no PTR";else print$3" is "$2}' | grep '('
2009-09-02 16:33:15
User: netsaint
Functions: awk grep
Tags: nmap dns
4

This command uses nmap to perform reverse DNS lookups on a subnet. It produces a list of IP addresses with the corresponding PTR record for a given subnet. You can enter the subnet in CDIR notation (i.e. /24 for a Class C)). You could add "--dns-servers x.x.x.x" after the "-sL" if you need the lookups to be performed on a specific DNS server.

On some installations nmap needs sudo I believe. Also I hope awk is standard on most distros.

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.

diff <(nmap -sP 192.168.1.0/24 | grep ^Host | sed 's/.appears to be up.//g' | sed 's/Host //g') auth.hosts | sed 's/[0-9][a-z,A-Z][0-9]$//' | sed 's/</UNAUTHORIZED IP -/g'
2009-03-12 05:28:08
User: bandit36
Functions: diff grep sed
Tags: diff sed nmap grep
1

populate the auth.hosts file with a list of IP addresses that are authorized to be in use and when you run this command it will return the addresses that are pingable and not in the authorized list.

Can be combined with the "Command line Twitter" command to tweet unauthorized access.