0

man netstat says

--numeric, -n

Show numerical addresses instead of trying to determine symbolic host, port or user names.

Does netstat output additional sockets with -n than without -n?

Or does netstat output the same set of sockets with -n as without -n?

They don't seem to output the same set of sockets:

$ sudo netstat -ap | wc -l
720
$ sudo netstat -anp | wc -l
719

-n seems to output sockets not shown otherwise:

$ sudo netstat -ap | grep 2049
$ sudo netstat -anp | grep 2049
tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      -                   
tcp6       0      0 :::2049                 :::*                    LISTEN      -                   
udp        0      0 0.0.0.0:2049            0.0.0.0:*                           -                   
udp6       0      0 :::2049                 :::*      
4

It's likely that one of the ports from the 720 list was simply removed in-between those runs; there should be no substantive difference in the number of outputs with or without -n.

You're seeing different output with the grep 2049 because the -n flag specifically shows "numerical addresses instead of trying to determine symbolic host, port names"; if you had grepped for ":nfs" instead of "2049" in the second example, you would have seen corresponding results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.