From 9642cd7ae24f0ba79ce5647c709b35ae8f06a285 Mon Sep 17 00:00:00 2001 From: Jasper Ras Date: Sun, 19 Jan 2025 21:14:51 +0100 Subject: vault backup: 2025-01-19 21:14:51 --- 3 resources/linux/LSOF.md | 69 ----------------------------------------------- 1 file changed, 69 deletions(-) delete mode 100644 3 resources/linux/LSOF.md (limited to '3 resources/linux/LSOF.md') diff --git a/3 resources/linux/LSOF.md b/3 resources/linux/LSOF.md deleted file mode 100644 index 5a3aa95..0000000 --- a/3 resources/linux/LSOF.md +++ /dev/null @@ -1,69 +0,0 @@ -#linux #how-to - ---- - -``` -lsof -p 1111 # show open files for this PID -lsof /path/to/file # show which process has this open -``` - -A usage in the wild; using lsof to find the qemu process for a specific base image and using that to get instance name and disk path: -``` -lsof -F p {{ item['path'] }} | cut -b 2- | head -1 | xargs ps | grep -oP '(instance\\-[a-z0-9]+)|(\\/var\\/lib\\/nova\\/instances\\/[a-z0-9\\-]+\\/disk)' | uniq -``` - -(man lsof: search "OUTPUT FOR OTHER PROGRAMS") -output for other programs -``` -specify -F -These are the fields that lsof will produce. The single character listed first is the field identifier. - a file access mode - c process command name (all characters from proc or - user structure) - C file structure share count - d file's device character code - D file's major/minor device number (0x) - f file descriptor (always selected) - F file structure address (0x) - G file flaGs (0x; names if +fg follows) - g process group ID - i file's inode number - K tasK ID - k link count - l file's lock status - L process login name - m marker between repeated output - M the task comMand name - n file name, comment, Internet address - N node identifier (ox - o file's offset (decimal) - p process ID (always selected) - P protocol name - r raw device number (0x) - R parent process ID - s file's size (decimal) - S file's stream identification - t file's type - T TCP/TPI information, identified by prefixes (the - `=' is part of the prefix): - QR= - QS= - SO= (not all dialects) - SS= (not all dialects) - ST= - TF= (not all dialects) - WR= (not all dialects) - WW= (not all dialects) - (TCP/TPI information isn't reported for all supported - UNIX dialects. The -h or -? help output for the - -T option will show what TCP/TPI reporting can be - requested.) - u process user ID - z Solaris 10 and higher zone name - Z SELinux security context (inhibited when SELinux is disabled) - 0 use NUL field terminator character in place of NL - 1-9 dialect-specific field identifiers (The output - of -F? identifies the information to be found - in dialect-specific fields.) - -``` \ No newline at end of file -- cgit v1.2.3