View Open Files

# Processes working on a file
lsof <filename>
 
# Files Open by a process
lsof -p <pid>
 
# View files currently open by a User
lsof -u <username>

View Port Information

lsof -i :<port>
lsof -i <protocol>

PID of Process

pidof <process-name>

Flags
-p: Port
-u: Username
-i: Listen to IP Sockets
-n: Disable DNS Lookup
-P: Show Port Number