lsof
ProcessesAdvanced In real LinuxList open files and network connections
Name: lsof = list open files
This command needs a real Linux system; you can practise it in real Linux mode.
Description
lsof lists files opened by processes. Since everything is a file on Linux, that includes directories, devices, pipes and network sockets.
Use it to find who holds a port (lsof -i :80), why a partition won't unmount (lsof /mnt/usb) or why deleted files still take space.
Syntax
lsof [OPTION]...Common options
| -i | Network connections, e.g. -i :80 for port 80 |
| -p PID | Files opened by a process |
| -u USER | Files opened by a user |
| -c NAME | Only processes whose command starts with NAME |
| +D DIR | Who has files open under DIR (when unmounting fails) |
| -t | Print only process IDs (kill $(lsof -t -i :8080)) |
| -n | Do not look up host names (faster) |
| -P | Numeric ports, not service names |