> ## Documentation Index
> Fetch the complete documentation index at: https://docs.domino.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# The lsof utility - 'list open files'

> Troubleshoot open files, network ports, and process locks on Linux using lsof basic and advanced command examples.

**Version/Environment (if relevant):** Applicable to any Linux-based system including Domino deployments.

## Issue:

Administrators and engineers need to identify processes holding file locks, investigate socket activity, or troubleshoot process ID (PID) conflicts on a Linux-based system.

## Root Cause:

This is a reference article for the `lsof` utility.

## Resolution:

### What is lsof?

`lsof` lists open files on Linux-based systems. It displays information about file descriptors and the processes that hold them open, including network connections and listening ports. Use `lsof` to identify processes holding file locks, investigate socket activity, and troubleshoot process ID (PID) conflicts.

> ⚠️ **Prerequisite:** `lsof` may require privilege elevation to access files belonging to other users. Prepend `sudo` to any command when running as a non-root user.

**Basic usage**

Use the following commands to troubleshoot open files on a Linux system:

Find all open files for a user:

```
lsof -u <username>
```

Find all open files associated with a particular process using a PID:

```
lsof -p <PID>
```

List and locate all open socket files:

```
lsof +D / -a -d sock
```

Locate all open files listening on a specific port:

```
lsof -i :<port number>
```

Identify all open files linked to an application by program name:

```
lsof -c <program name>
```

**Advanced usage**

Use these commands for more targeted investigation across processes, file descriptors, and time intervals:

Display the process name, PID, and file name for all open files at a set time interval:

```
lsof -n -r <time interval> +L -F pn -F f
```

Locate all open files for a specific process at a set time interval and sort by PID:

```
lsof -p <PID> -n -r <time interval> +L -s
```

Find all open files and the command line that opened them:

```
lsof -c <command name> -a -c <command name> +L1
```

Find all open files linked to a specific file descriptor:

```
lsof -a -d <file descriptor>
```

### Notes/Information:

* `lsof` can also help identify processes blocking a filesystem unmount. Running `lsof <filesystem_name>` will display all open files on the named filesystem.
* `lsof +L1` can be used to find unlinked open files on local disks — files that have been deleted but are still held open by a process, which can cause unexpected disk usage.


## Related topics

- [How-to guides](/knowledge-base/how-to-guides-overview.md)
- [Database Locking](/knowledge-base/database-locking.md)
- [Monitor application execution logs](/cloud/admin/operations/audit-logs/application-logs.md)
- [uwsgi: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory](/knowledge-base/uwsgi-error-while-loading-shared-libraries-libpcre-so-1-cannot-open-shared-object-file-no-such-file-or-directory.md)
