lsof commands
19 commands, each with a one-line explanation. Click a command to copy it, or its title for details.
Commands 19 shown
-
lsof -p $(pgrep nginx) | head -30Show all files (sockets, regular, pipes) opened by nginx
-
lsof -i :8080Find which process is listening on port 8080
-
lsof -i -n -PShow all open network connections without DNS resolution
-
lsof +D /var/logShow all processes with open files under /var/log
-
lsof | grep '(deleted)'Find files deleted but still held open by processes (disk bloat)
-
ss -tlnpShow TCP listening ports with process names
-
ss -tanp | grep ESTABFilter established TCP connections with process info
-
ss -ulnpList UDP listening ports with process names
-
ss -sPrint socket usage summary by state
-
ss -tnp dst :443Show connections going TO port 443
-
lsof -nP -i :<port>Show which process owns a port; -nP skips DNS/service name lookups for speed
-
lsof -nP -iTCP -sTCP:LISTENList every TCP listener with PID, no name resolution; modern: ss -ltnp
-
lsof +L1Find unlinked files still held open eating disk; df shows full but du does not
-
lsof /mnt/<name>Reveal processes blocking a 'device busy' umount; pass the mountpoint path
-
lsof -t -i:<port> | xargs -r killKill whatever owns a port; -t prints bare PIDs, -r avoids running kill on empty input
-
lsof -nP -i -sTCP:CLOSE_WAITSpot sockets the app forgot to close; growing CLOSE_WAIT = fd/connection leak
-
lsof -nP -i @<host>:<port>Show only sockets talking to a specific peer host/port, both ends matched
-
lsof -p <pid> -a -d txt,memShow only mapped executable and shared libs; -a ANDs the filters, great after a deploy
-
lsof -nP -p <pid> | wc -lQuick fd count to spot leaks vs ulimit -n; faster: ls /proc/<pid>/fd | wc -l
no commands match — try a different search