Which command can I use in ubuntu to see active tcp connections?
- User
Which command can I use in ubuntu to see active tcp connections?
- Assistant
To see active TCP connections in Ubuntu, you can use the
netstatcommand with the following options:codenetstat -tuanpHere's what each option means:
-t: Show TCP connections.-u: Show UDP connections.-a: Show all connections, including listening sockets.-n: Show numerical addresses instead of trying to determine symbolic host, port, or user names.-p: Show the PID and name of the program to which each socket belongs.
Alternatively, you can use the
sscommand, which is a more modern replacement fornetstat. The equivalent command usingsswould be:codess -tuanpBoth commands will display a list of active TCP and UDP connections, along with the local and remote addresses, port numbers, connection state, and the associated process ID (PID) and name.
Note: You may need to run these commands with
sudoto see all the connections, especially those belonging to processes running with root privileges.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.