Windows
Linux
Services & Processes
Processes
Windows openfiles equivalent in Linux
Shows which files, sockets, and devices are currently open and by which processes.
Windows
→
openfiles
Linux equivalents
lsof
lsof
lsof
Overview
What this command does
Shows which files, sockets, and devices are currently open and by which processes.
Migration tip:
lsof (List Open Files) is extremely powerful. In Linux, everything is a file — network sockets, devices, and pipes all appear in lsof output.Practical tasks
Common use cases
List open files and which process uses them
Shows which files, sockets, and devices are currently open and by which processes.
lsof -u john
Files opened by user john
lsof -p 1234
Files opened by process 1234
lsof /var/log/syslog
Who has this file open?
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
lsof -i :80
lsof -p $(pidof nginx)
lsof /var/log/app.log
Walkthrough
Examples with explanations
# Windows: openfiles /query
# What process is using port 80?
lsof -i :80
# What files does nginx have open?
lsof -p $(pidof nginx)
# Who has this log file open?
lsof /var/log/app.log
Reference
Common options and variations
| Command or option | Use |
|---|---|
lsof -u john | Files opened by user john |
lsof -p 1234 | Files opened by process 1234 |
lsof /var/log/syslog | Who has this file open? |
lsof -i :80 | What process is using port 80? |
lsof -i tcp | All open TCP connections |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | same command | lsof |
Same command on this distribution. |
| Fedora | same command | lsof |
Same command on this distribution. |
| Arch | same command | lsof |
Same command on this distribution. |
Keep learning