Skip to content

Processes and Network Ports ​

This page covers how to check running processes (PID) together with how to check the network ports those processes have opened.

Process Management (PID) ​

Concept ​

A process is a running program. Each process is assigned a unique PID (Process ID) number.

Key Commands ​

bash
# List all processes
ps aux

# Search for a specific process
ps aux | grep agent_app.py

# Terminate a process
kill <PID>
kill -9 <PID>    # force kill

# Real-time process monitoring
top
htop

How It Is Used in monitor.sh ​

bash
PID=$(pgrep -f agent_app.py)

if [ -z "$PID" ]; then
    echo "[ERROR] The process is not running."
    exit 1
fi

Networks and Ports ​

Concept ​

A port is a door for network communication. A server opens a specific port and waits for connections (LISTEN). A client connects to that port.

Key Commands ​

bash
# Check open ports
ss -tulnp

# Example output
# tcp  LISTEN  0  128  0.0.0.0:15034  ...  python3

# Check a specific port
ss -tulnp | grep 15034

Reading ss Output ​

ColumnMeaning
StateLISTEN = waiting for connections
Local Address:PortThe address:port the server has opened
0.0.0.0Receives on all network interfaces

Summary ​

ItemCommandNotes
List/search processesps aux, ps aux | grep agent_app.pyEach process has a unique PID
Terminate a processkill <PID>, kill -9 <PID>-9 forces termination
Real-time monitoringtop, htop
Get a PID in a scriptpgrep -f agent_app.pyexit 1 if empty
Check open portsss -tulnpLISTEN = waiting for connections, 0.0.0.0 = all interfaces

Source: Codyssey-B1/B4-1