2013-11-26 04:20:24 +01:00
|
|
|
# List all IPv4 network files
|
2013-10-09 00:16:31 +02:00
|
|
|
sudo lsof -i4
|
|
|
|
|
2013-11-26 04:20:24 +01:00
|
|
|
# List all IPv6 network files
|
|
|
|
sudo lsof -i6
|
|
|
|
|
2016-09-27 17:53:39 +02:00
|
|
|
# To find listening ports
|
2013-08-26 16:51:57 +02:00
|
|
|
lsof -Pnl +M -i4
|
2013-08-30 12:16:48 +02:00
|
|
|
|
2016-09-27 17:53:39 +02:00
|
|
|
# To list all open sockets
|
|
|
|
lsof -i
|
|
|
|
|
|
|
|
# To find which program is using the port 80
|
2013-09-01 19:30:44 +02:00
|
|
|
lsof -i TCP:80
|
2013-11-26 04:20:24 +01:00
|
|
|
|
2016-09-27 17:53:39 +02:00
|
|
|
# To show connections to a specific host
|
|
|
|
lsof -i@192.168.1.5
|
|
|
|
|
2013-11-26 04:20:24 +01:00
|
|
|
# List all processes accessing a particular file/directory
|
|
|
|
lsof </path/to/file>
|
|
|
|
|
|
|
|
# List all files open for a particular user
|
|
|
|
lsof -u <username>
|
|
|
|
|
2016-09-27 17:53:39 +02:00
|
|
|
# List all files/network connections a command is using
|
2013-11-26 04:20:24 +01:00
|
|
|
lsof -c <command-name>
|
|
|
|
|
2016-09-27 17:53:39 +02:00
|
|
|
# List all files a process has open
|
|
|
|
lsof -p <pid>
|
|
|
|
|
|
|
|
# Lists all files open mounted at /mount/point.
|
|
|
|
# Particularly useful for finding which process(es) are using a
|
|
|
|
# mounted USB stick or CD/DVD.
|
|
|
|
lsof +f -- </mount/point>
|
|
|
|
|
2013-11-26 04:20:24 +01:00
|
|
|
# See this primer: http://www.danielmiessler.com/study/lsof/
|
|
|
|
# for a number of other useful lsof tips
|