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

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 :)


Solution 1:

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

Solution 2:

Alternatively, you could use lsof -i which shows you the user.

COMMAND     PID    USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
httpd     32500  apache    4u  IPv6   14390      0t0  TCP *:http (LISTEN)
httpd     32501  apache    4u  IPv6   14390      0t0  TCP *:http (LISTEN)
httpd     32502  apache    4u  IPv6   14390      0t0  TCP *:http (LISTEN)
httpd     32503  apache    4u  IPv6   14390      0t0  TCP *:http (LISTEN)