codeaprendiz.github.io

DevOps Essentials

View on GitHub

lsof

NAME

lsof - list open files

SYNOPSIS

lsof [ -?abChKlnNOPRtUvVX ] [ -A A ] [ -c c ] [ +c c ] [ + -d d ] [ + -D D ] [ + -e s ] [ + -E ] [ + -f [cfgGn] ] [ -F [f] ] [ -g [s] ] [ -i [i] ] [ -k k ] [ + -L [l] ] [ + -m m ] [ + -M ] [ -o [o] ] [ -p s ] [ + -r [t[m]] ] [ -s [p:s] ] [ -S [t] ] [ -T [t] ] [ -u s ] [ + -w ] [ -x [fl] ] [ -z [z] ] [ -Z [Z] ] [ – ] [names]

DESCRIPTION

Lsof revision 4.89 lists on its standard output file information about files opened by processes for the following UNIX dialects:

An open file may be a regular file, a directory, a block special file, a character special file, an executing text reference, a library, a stream or a network file (Internet socket, NFS file or UNIX domain socket.) A specific file or all the files in a file system may be selected by path.

Instead of a formatted display, lsof will produce output that can be parsed by other programs. See the -F, option description, and the OUTPUT FOR OTHER PROGRAMS section for more information.

In addition to producing a single output list, lsof will run in repeat mode. In repeat mode it will produce output, delay, then repeat the output operation until stopped with an interrupt or quit signal. See the + -r [t[m]] option description for more information.

OPTIONS

EXAMPLES

$ lsof -i :8000
COMMAND   PID USER   FD TYPE         DEVICE SIZE/OFF NODE NAME
Python  67100 asr000p    7u IPv4 0x2daeb57757439a85      0t0 TCP localhost:irdmi (LISTEN)
sudo lsof -i -P -n | grep LISTEN
sshd    85379   root 3u  IPv4 0xffff80000039e000      0t0 TCP 10.86.128.138:22 (LISTEN)