Image of Austin Gatlin's face
February 28, 2022 (last updated March 1, 2022)


It lists (ls) open files. Among other things, these open files include network files like internet sockets, UNIX domain sockets, etc.

lsof flags

  • -i

    By itself, it will list all the open internet and network files. Otherwise, it will attempt to match the provided argument, which should be an internet address specified as follows: [46][protocol][@hostname|hostaddr][:service|port]. E.g., :3000.

  • -n

    Tells lsof to not convert IP addresses to hostnames. The lookup times for the hostnames can drastically affect the time it takes to run lsof. I'm guessing this is because the lsof service has to reach out to the internet and check DNSs until it finds one that knows the hostname of the IP address it's checking against.

  • -t

    Lists tersely. I.e., it lists just the PIDs.

lsof Examples

  • lsof -i :3000 will list every open network file listening on port :3000

  • lsof -nti :3000 will list just the PIDs listening on port :3000

  • lsof -n | grep LISTEN will list every listening process/open-file