Find which process holds a port or a file.
lsof
Find the process on a port
lsof -i :8080 -sTCP:LISTEN
Find who has a file open
lsof /var/log/nginx/access.log
Why a delete is failing
lsof +D /var/lib/thing | head
All open files for one process
lsof -p <pid>
On modern systems
ss -tlnp answers the port question without lsof. Use lsof for file descriptors, which ss does not cover.