Harness the Combinatoric Power of Command-Line Tools and Utilities
See Open Network Connections
Published May 17, 2024
To quickly see the open network connections, use the lsof
command.
sudo lsof -T -i -n
-T
specifies that the output should include TCP information. This option can take arguments to specify what type of TCP information to include:-T f
: Includes file descriptor information.-T info
: Includes information about the TCP state, likeESTABLISHED
orLISTENING
.-T text
: Includes the TCP state in text form, likeESTABLISHED
orSYN_SENT
.
Without additional arguments, it shows the TCP state.
-i
: Lists information about network files, such as network connections.-i4
: Shows only IPv4 network connections.-i6
: Shows only IPv6 network connections.
Without additional arguments, it shows all network connections.
-n
: Prevents conversion of IP addresses to host names, port numbers to service names, and user IDs to user names. This makes the command run faster and avoids DNS lookups.
Adding the -r
switch will refresh the results:
sudo lsof -T -i -n -r
Press CTRL+C
to return to your prompt.