Linux Process & Port Management

Source: raw/linux/bash command.md.

View processes

ps aux                  # detailed list
ps -ef                  # another common format
ps -eo pid,ppid,cmd     # custom columns

Find a specific process

ps aux | grep "process_name"
pgrep -l "process_name"     # PIDs + names
pidof "process_name"        # PID(s)

Check open ports

sudo netstat -tulpn                 # all listening ports + process info
sudo netstat -tulpn | grep LISTEN
sudo ss -tulpn                      # modern alternative
sudo ss -tulpn | grep :8080
sudo lsof -i :8080

Terminate

kill PID          # SIGTERM (graceful, == kill -15)
kill -9 PID       # SIGKILL (force)
pkill process_name
pkill -f "full_command"
killall process_name

Open questions

  • systemctl / service management (see docker-cli-basics).
  • top / htop / nice / renice for CPU priority.