To find files that are currently open on Linux, use lsof, for example sudo lsof /var/log/syslog to check a particular path. The find command searches directory contents and file properties; it does not report which files running processes have open.
What “open files” means on Linux
Linux programs interact with files through file descriptors: small numbers a process uses to refer to an open resource. A descriptor may refer to a regular file, but it can also refer to a directory, device, pipe, socket, or other resource. Commands that list open files can therefore show more than documents stored on disk.
Finding open files is useful when a log is not shrinking after rotation, a disk appears full even after a file was deleted, or you need to identify which process is using a file or listening on a port. It can also help before unmounting a filesystem. The result is a snapshot: processes can open or close resources while the command runs, so a listing may change immediately afterward.
The name of the task can be confusing. If you mean “search the filesystem for a file by name,” use find. If you mean “show files currently held open by processes,” use lsof, fuser, or information exposed through /proc.
Use lsof for a general listing
lsof means “list open files” and is the most direct general-purpose tool for this job. Run it without arguments to request a system-wide listing:
sudo lsofshows open resources visible to the command, often across many processes.lsof /path/to/filelists processes that have that path open.lsof -p 2468lists open resources associated with process ID 2468.lsof -u alicefilters for processes owned by the user alice.
System-wide output can be very long. A typical row includes the command name, process ID, user, file descriptor, resource type, device and inode details, and a name or endpoint. The descriptor column may include values such as 3r for a descriptor opened for reading or 4w for one opened for writing. Exact columns and formatting vary by version and platform.
On some distributions, lsof is not installed by default. Install the package using the system’s package manager if the shell reports that the command is missing. Package names and commands differ between distributions. Running it with sudo usually reveals more system processes, but elevated access is not a guarantee that every container, namespace, or restricted process will be visible from the current environment.
Narrow the search to a path, process, or port
Filtering makes results easier to interpret. To inspect a file or directory, provide its path. To check a directory tree recursively, use lsof +D /var/www. This can take a long time on a large tree because the tool examines entries throughout it; for a single known file, use the direct path instead. A directory listing may also include files opened through paths beneath that directory, depending on the command and filesystem state.
To identify a process’s resources, first obtain its PID with a tool such as ps, then run sudo lsof -p PID, replacing PID with the number. This is useful when investigating a service. If a process has many descriptors, combine the listing with a narrow question—for instance, look for a particular filename or a descriptor marked as a socket—rather than trying to infer the problem from every row.
For network endpoints, lsof -i lists network-related open files. To check which process is listening on TCP port 8080, try sudo lsof -iTCP:8080 -sTCP:LISTEN -P -n. The -P option keeps port numbers numeric, and -n avoids resolving IP addresses to hostnames. For a quick view focused specifically on sockets and listening ports, ss -ltnp is another useful tool; it is not a general replacement for inspecting regular files.
Use fuser when you know the file or mount
fuser answers a closely related question: which process is using a specified file, directory, or filesystem? For example, sudo fuser -v /var/log/syslog displays process information for users of that path. It can be a quicker choice than scanning a large lsof listing when you already know the target.
To check what is using a mount point, you can run sudo fuser -vm /mnt/archive. The -m option treats the argument as a mounted filesystem, while -v requests a more descriptive listing. Read the output carefully: a process may be using the filesystem through a file, a current working directory, or another reference, not only by writing a file you can see in a directory listing.
fuser -k can send a signal to processes using a target, but it is not a harmless diagnostic option. Killing a database, editor, or system service can interrupt work or cause data loss. Identify the process and choose an appropriate shutdown method before taking action; do not add -k simply to make a busy mount command succeed.
Inspect descriptors through /proc
Linux exposes process details through the /proc virtual filesystem. For a process with PID 2468, its open descriptors are represented by entries under /proc/2468/fd/. You can inspect them with ls -l /proc/2468/fd. The entries are symbolic links that point to the resource associated with each descriptor, where permissions allow you to read them.
This is useful when lsof is unavailable or when you want to understand what the listing represents. For example, descriptor 1 commonly refers to standard output and descriptor 2 to standard error, though a program can redirect or repurpose them. A link ending in (deleted) can indicate that a process still has an unlinked file open. It does not mean the data has vanished immediately: the storage can remain allocated until the last open reference is closed.
Reading /proc manually is less convenient for a system-wide search. You would need to inspect descriptor directories for multiple PIDs, and access controls may hide details. Processes can also exit while you are looking, making a path disappear between commands. Treat it as a useful interface for investigation, not as a perfectly stable inventory.
Find deleted files that still use disk space
A common surprise is that deleting a large file does not always free space at once. Unlinking removes a directory entry, but a running process can continue using the file through an open descriptor. The file may no longer appear in an ordinary directory listing, yet its blocks remain allocated until the process closes the descriptor or exits.
To look for this situation with lsof, run sudo lsof +L1. This selects open files with a link count below one, which commonly identifies unlinked files still held open. Check the process and file details before acting. If a service is retaining an old log, use that service’s documented log-reopen or restart procedure when appropriate; removing or truncating files blindly can disrupt an application.
This explains why df and du can appear to disagree. df reports filesystem space usage, including blocks retained by open unlinked files. A directory-based tool such as du totals files it can traverse by name and may not include those blocks. The discrepancy is a clue to investigate, not proof by itself that a deleted open file is the cause.
Why results can be incomplete or confusing
Permission is the first common limitation. A regular user may see their own processes but not be allowed to inspect another user’s descriptors or process details. Try the command with sudo if you are authorized to do so. In managed systems, security policies, containers, or separate PID and mount namespaces can still make the view differ from what another host or namespace sees.
Path matching also has limits. A file can be renamed or unlinked after a process opens it, so the displayed name may be marked as deleted or may not match the path you expected. Two different paths can refer to the same underlying file, and a process may access a resource through a mount or namespace not obvious from the host’s directory tree. When the name looks unfamiliar, compare the PID, descriptor, device, and inode information rather than relying on the path alone.
Finally, an empty result does not always mean no process is using the resource. The process may have closed it, the path may have changed, or your command may be running in a different namespace. Repeat the check, inspect the relevant process, and use a second view such as fuser or /proc/PID/fd when the distinction matters.
Choose a command and act safely
For most investigations, start with the narrowest command that matches the question. Use lsof /path for a known file, lsof -p PID for one process, fuser -v for a known target, and lsof -i or ss for network activity. Use a full system listing only when the target is unknown, because broad output is harder to interpret and may require elevated privileges.
Listing is observational; changing the process is a separate decision. A process holding a file open may be behaving normally. Before stopping it, confirm its identity and purpose, consider whether it is handling active work, and prefer its normal service-management or application-specific procedure. Avoid copying a PID from stale output and sending a signal without checking that the process is still the same one.
If the goal is simply to locate files by name, size, age, or type, use find, such as find /var/log -type f -name '*.log'. That searches directory entries, not open descriptors. Keeping these two tasks distinct prevents a common mistake: expecting a filesystem search to reveal which live program has a file in use.
Frequently Asked Questions
Can the find command show files that are open?
No. The standard find command searches filesystem paths and properties, not the live file descriptors held by processes. Use lsof or fuser to identify current users of a file.
How do I see which process is using a file?
Run sudo lsof /path/to/file or sudo fuser -v /path/to/file. The output includes process identifiers that you can investigate with tools such as ps.
How can I find which process is using a port?
For example, run sudo lsof -iTCP:8080 -sTCP:LISTEN -P -n to check TCP port 8080 for a listener. You can also use sudo ss -ltnp to list listening TCP sockets and process information where permitted.
Why does a deleted file still take up disk space?
A process may still have the file open after its directory entry has been removed. Check with sudo lsof +L1; the space is normally released when the remaining open reference is closed.
Why does lsof show no output for a file?
The file may not be open at the moment of the check, its name or mount context may have changed, or permissions and namespaces may limit visibility. Try an authorized elevated check and compare with fuser or the relevant /proc/PID/fd entries.