linux-connections

Queries TCP/IP network connection information on a Linux system. Parses protocol-specific files in the /proc/net/ directory and collects socket inode-to-process ID mappings from the /proc/ directory to return detailed information for each connection as structured fields.

Command properties

PropertyValue
Command typeDriver query
Required permissionAdministrator
License usageCounted
Parallel executionNot supported
Distributed executionRuns on Data Node (mapper)

Syntax

linux-connections

Output fields

FieldTypeDescription
pidintegerProcess ID. Returns null if no process corresponding to the socket inode is found.
rx_queuelongReceive queue length (bytes)
tx_queuelongTransmit queue length (bytes)
protocolstringProtocol. One of: tcp, tcp6, udp, udp6, raw, raw6, icmp, icmp6
local_ipipaddrLocal IP address
local_portintegerLocal port number
remote_ipipaddrRemote IP address
remote_portintegerRemote port number
statestringConnection state. One of: UNKNOWN, ESTABLISHED, SYN_SENT, SYN_RECV, FIN_WAIT1, FIN_WAIT2, TIME_WAIT, CLOSED, CLOSE_WAIT, LAST_ACK, LISTEN, CLOSING

Error codes

Parsing errors
Error codeMessageDescription
95040no-read-permissionExecuted without administrator privileges
Runtime errors

N/A

Description

The linux-connections command collects TCP/IP network connection information from the following files:

  • /proc/net/tcp
  • /proc/net/tcp6
  • /proc/net/udp
  • /proc/net/udp6
  • /proc/net/raw
  • /proc/net/raw6
  • /proc/net/icmp
  • /proc/net/icmp6 (only if the file exists)

After parsing connection entries from each file, it queries file descriptor information for each process in the /proc/ directory to map socket inodes to process IDs. This allows the pid field to be assigned for each connection. If no process corresponding to the socket inode is found, the pid field is set to null.

This command requires administrator privileges. If privileges are insufficient, an error occurs at the parsing stage.

Examples

  1. Query all network connection information

    linux-connections
    

    Queries all TCP/IP network connection information on the current system.

  2. Query TCP connections in LISTEN state

    linux-connections
    | search state == "LISTEN" and protocol == "tcp"
    

    Filters only connections using the TCP protocol that are in LISTEN state.

  3. Aggregate connection count by protocol

    linux-connections
    | stats count by protocol
    

    Aggregates the connection count by protocol.