From 809c6d77bc36d234af94822e8ce981a2e02d61b7 Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Tue, 27 Sep 2016 21:23:39 +0530 Subject: [PATCH 1/2] Update lsof sheet --- cheat/cheatsheets/lsof | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cheat/cheatsheets/lsof b/cheat/cheatsheets/lsof index cc19485..5e54960 100644 --- a/cheat/cheatsheets/lsof +++ b/cheat/cheatsheets/lsof @@ -4,20 +4,34 @@ sudo lsof -i4 # List all IPv6 network files sudo lsof -i6 -# To find listening ports: +# To find listening ports lsof -Pnl +M -i4 -# To find which program is using the port 80: +# To list all open sockets +lsof -i + +# To find which program is using the port 80 lsof -i TCP:80 +# To show connections to a specific host +lsof -i@192.168.1.5 + # List all processes accessing a particular file/directory lsof # List all files open for a particular user lsof -u -# List all files/network connections a given process is using +# List all files/network connections a command is using lsof -c +# List all files a process has open +lsof -p + +# 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 -- + # See this primer: http://www.danielmiessler.com/study/lsof/ # for a number of other useful lsof tips From cdf240b70e39e579a5daba1dc3c0593e54f76aea Mon Sep 17 00:00:00 2001 From: Shadab Zafar Date: Tue, 27 Sep 2016 22:43:54 +0530 Subject: [PATCH 2/2] Fix grammar of lsof --- cheat/cheatsheets/lsof | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cheat/cheatsheets/lsof b/cheat/cheatsheets/lsof index 5e54960..8d11e3f 100644 --- a/cheat/cheatsheets/lsof +++ b/cheat/cheatsheets/lsof @@ -4,16 +4,16 @@ sudo lsof -i4 # List all IPv6 network files sudo lsof -i6 -# To find listening ports -lsof -Pnl +M -i4 - -# To list all open sockets +# List all open sockets lsof -i -# To find which program is using the port 80 +# List all listening ports +lsof -Pnl +M -i4 + +# Find which program is using the port 80 lsof -i TCP:80 -# To show connections to a specific host +# List all connections to a specific host lsof -i@192.168.1.5 # List all processes accessing a particular file/directory @@ -28,7 +28,7 @@ lsof -c # List all files a process has open lsof -p -# Lists all files open mounted at /mount/point. +# List 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 --