Linux, netstat : how to display the owner of programs using ports

linuxnetstatnetworking

I'm getting crazy with the command netstat.
In the man we can read that, in the output of Active Internet Connections (TCP, UDP, raw) we should have :

User : The username or the user id (UID) of the owner of the socket.

But when I do

netstat -natp

my output doesn't show any owner (or UID)

Active Internet connections (servers and established)  
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name  
tcp        0      0 0.0.0.0:4713            0.0.0.0:*               LISTEN      2159/pulseaudio  
(...)

and I don't see any option in the man to display the owner of the PID.

There is the --numeric-users option, but it doesn't change anything.

Is there something I'm missing? Or there is something wrong with netstat ?
Is there another way to get this information?

Thanks for your help 🙂

Best Answer

Use netstat -natpe.

From the man page:

-e, --extend
 Display additional information.  Use this option twice for maximum detail.

As clear as mud.

Which will add two columns, User and Inode to the display.

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       User       Inode      PID/Program name
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      100        13119      1901/mysqld
Related Question