# lsof

##### Network Port

What process is using the port 50000

```shell
lsof -i :50000

lsof -i :https

lsof -i tcp:25

lsof -i udp:53

lsof -i :1-1024

lsof -i udp
```

##### Mount Point

What process is using the mount-point

```shell
lsof | grep /path/to/mount-point

lsof +f -- /path/to/dir

lsof +D /path/to/dir

# List all NFS files
lsof -N
```

##### Process

What files and directories are using by the process

```shell
lsof -p `pidof <app_name>`

lsof -c apache

lsof | grep apache

# list Parent PID of processes
lsof -p [PID] -R
```

##### User

```shell
# List files opened by processes belonging to a specific user
lsof -u [user-name]

lsof -a -i -u www-data
```

##### IP &amp; Domain

List files based on their Internet address

```shell
# For IPv4
lsof -i 4

# For IPv6
lsof -i 6
```

##### File

```shell
lsof -t [file-name]
lsof -t /usr/lib/x86_64-linux-gnu/libpcre2-8.so.0.9.0

# Finding open files in a specific directory under Linux or Unix
lsof +D /path/to/dir/

# list any open files which have been removed or deleted
lsof -nP +L1
lsof -nP +L1 +D /path/to/dir/
```

##### Memory

```shell
lsof -d mem
```