Linux Commands / IT Support Guides
Identify a file owner with lsof
Find which Linux process currently has a specific file open.
Environment and inputs: Linux · Bash-compatible shell; package and service names vary by distribution
Understand the problem
Choose the exact file path. Use the machine on which the process runs and an account allowed to inspect it.
Run the command
Run lsof with the file path, replacing /var/log/app/app.log with the file you are checking.
lsof /var/log/app/app.log
Read the output
Read COMMAND, PID, and USER to identify the process and account. In the FD column, a value such as 4w means file descriptor 4 is open for writing.
Choose the next step
If you see a match, check whether the process belongs to the expected service. If the list is empty, verify the path and consider whether the file was closed before the check or whether permission limits what you can see.
Before making changes
Capture the process name and PID before acting. Use the service’s documented procedure for reopening or rotating its logs.