Skip to content

/errors/ss/ss-command-not-found

bash: ss: command not found

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
ss / netstat
exit code
127
versions
iproute2
os
linux, macos

bash: ss: command not found means the shell found no ss program in any directory of PATH. ss (socket statistics) is part of the Linux iproute2 package, which minimal container images often leave out, and it does not exist on macOS. Install the package (apt-get install iproute2 on Debian/Ubuntu, dnf install iproute on Fedora/RHEL, apk add iproute2 on Alpine), or use lsof or netstat on macOS.

Reproduce it

Simulate a system without ss by running it with an empty PATH:

bash
(PATH=/nonexistent; ss -tlnp)
echo "exit code: $?"

Output

bash: line 1: ss: command not found
exit code: 127

Exit code 127 is the shell's code for "command not found"; ss itself never ran.

Install it

SystemCommandPackage
Debian, Ubuntuapt-get update && apt-get install -y iproute2iproute2
Fedora, RHEL, Rocky, Almadnf install -y iprouteiproute
Alpineapk add iproute2iproute2
Archpacman -S iproute2iproute2
openSUSEzypper install iproute2iproute2

Run these as root (or with sudo). In a Dockerfile, add the package to the image instead of installing it into a running container, which loses it on the next restart.

Without installing anything

  • In a container, run ss from the host in the container's network namespace: nsenter -t PID -n ss -tlnp, where PID is the container's main process on the host (docker inspect -f '{{.State.Pid}}' NAME).
  • Read the kernel tables directly: cat /proc/net/tcp /proc/net/tcp6 (ports are in hexadecimal).
  • On macOS: lsof -nP -iTCP -sTCP:LISTEN lists listening TCP sockets with their processes; netstat -an -p tcp lists all TCP sockets.

Found as root but not as a user

On some distributions ss lives in /usr/sbin or /sbin, which is in root's PATH but not always in a normal user's or a cron job's. Check with ls -l /usr/sbin/ss /sbin/ss; if it is there, call it by full path or add the directory to PATH.

Sources