Harness the Combinatoric Power of Command-Line Tools and Utilities

../Tips

See Open Network Connections

commands

Published May 17, 2024

Warning

❗ This article is more than six months old. Some things may not work as written.

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, like ESTABLISHED or LISTENING.
    • -T text: Includes the TCP state in text form, like ESTABLISHED or SYN_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.