From b107435793478595a99ff1654024b9e8fae56422 Mon Sep 17 00:00:00 2001 From: Yoshinari Takaoka Date: Mon, 4 Jan 2016 03:47:24 +0900 Subject: [PATCH 1/5] lsof: add -u, -c example and note about privileges --- pages/common/lsof.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pages/common/lsof.md b/pages/common/lsof.md index fa5ae6492..89989725b 100644 --- a/pages/common/lsof.md +++ b/pages/common/lsof.md @@ -1,6 +1,7 @@ # lsof > Lists open files and the corresponding processes +> Note: In most case, you need root privilege (or sudo) because you want to list files opened by other than you. - find the processes that have a given file open @@ -13,3 +14,11 @@ - only output the process PID (e.g. to pipe into kill) `lsof -t {{/path/to/file}} | xargs kill -9` + +- list files opened by user + +`lsof -u {{username}}` + +- list files opened by command (or process) name (e.x nginx) + +`lsof -c {{process_or_command_name}}` From 7d7a50568ffddb7a4072aff6627dc685efec6ea1 Mon Sep 17 00:00:00 2001 From: Yoshinari Takaoka Date: Wed, 6 Jan 2016 06:24:23 +0900 Subject: [PATCH 2/5] replaced {{8080}} with {{port}} to follow format conventions. --- pages/common/lsof.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/common/lsof.md b/pages/common/lsof.md index 89989725b..c200bf37b 100644 --- a/pages/common/lsof.md +++ b/pages/common/lsof.md @@ -9,7 +9,7 @@ - find the process that opened a local internet port -`lsof -i :{{8080}}` +`lsof -i :{{port}}` - only output the process PID (e.g. to pipe into kill) From 28f29660c33d2f3ed5b805fe882b50777733e00d Mon Sep 17 00:00:00 2001 From: Yoshinari Takaoka Date: Wed, 6 Jan 2016 06:26:36 +0900 Subject: [PATCH 3/5] removed kill -9 pipe. --- pages/common/lsof.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/common/lsof.md b/pages/common/lsof.md index c200bf37b..22df47bb6 100644 --- a/pages/common/lsof.md +++ b/pages/common/lsof.md @@ -13,7 +13,7 @@ - only output the process PID (e.g. to pipe into kill) -`lsof -t {{/path/to/file}} | xargs kill -9` +`lsof -t {{/path/to/file}}` - list files opened by user From 7a01d25b6f5a943ce5e48d8dad4b1d37bae21a30 Mon Sep 17 00:00:00 2001 From: Yoshinari Takaoka Date: Wed, 6 Jan 2016 06:29:14 +0900 Subject: [PATCH 4/5] fixed poor english :( --- pages/common/lsof.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pages/common/lsof.md b/pages/common/lsof.md index 22df47bb6..44e6d38f4 100644 --- a/pages/common/lsof.md +++ b/pages/common/lsof.md @@ -1,7 +1,7 @@ # lsof > Lists open files and the corresponding processes -> Note: In most case, you need root privilege (or sudo) because you want to list files opened by other than you. +> Note: In most cases, you need root privilege (or use sudo) because you want to list files opened by others - find the processes that have a given file open @@ -15,10 +15,10 @@ `lsof -t {{/path/to/file}}` -- list files opened by user +- list files opened by the given user `lsof -u {{username}}` -- list files opened by command (or process) name (e.x nginx) +- list files opened by the given command or process (e.x nginx) `lsof -c {{process_or_command_name}}` From b8d24b5f74b3b9400ae4fd90fb76345c1f84bc32 Mon Sep 17 00:00:00 2001 From: Yoshinari Takaoka Date: Sun, 10 Jan 2016 21:33:09 +0900 Subject: [PATCH 5/5] - deleted unnecessary descriptions. --- pages/common/lsof.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/common/lsof.md b/pages/common/lsof.md index 44e6d38f4..36769f14c 100644 --- a/pages/common/lsof.md +++ b/pages/common/lsof.md @@ -11,7 +11,7 @@ `lsof -i :{{port}}` -- only output the process PID (e.g. to pipe into kill) +- only output the process PID `lsof -t {{/path/to/file}}` @@ -19,6 +19,6 @@ `lsof -u {{username}}` -- list files opened by the given command or process (e.x nginx) +- list files opened by the given command or process `lsof -c {{process_or_command_name}}`