# Lsof examples

**URL:** <https://linux-tips.com/t/lsof-examples/182>\
**Category:** Shell\
**Created:** [June 23, 2008, 10:14am UTC](https://linux-tips.com/t/lsof-examples/182 "2008-06-23T10:14:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![demirten](https://linux-tips.com/user_avatar/linux-tips.com/demirten/32/64_2.png) [@demirten](https://linux-tips.com/u/demirten)\
**Post date:** [June 23, 2008, 10:14am UTC](https://linux-tips.com/t/lsof-examples/182/1 "2008-06-23T10:14:26Z")

</div>

lsof is one of the not well known but very powerfull utility in Linux.

```
man lsof

```

basically says that lsof: list open files. But there is more.

You can use it for managing and tracking network connections, list open ports, identify connections currently being made to your system, and determine what resources a process is using. Not only that, but you can also determine what processes a particular user has and find detailed information about file and directory usage. Here some example usages:

List all open files in system:

```
lsof

```

List all network connections:

```
lsof -i

```

List all UDP connections:

```
lsof -iUDP

```

List connections on specific port number:

```
lsof -i :80

```

List connections on specific host:

```
lsof -i@10.105.2.3

```

List connection on specifics host and port:

```
lsof -i@10.105.2.3:80

```

List all of the ipv6 connections:

```
lsof -i 6

```

List all files opened by user fred:

```
lsof -u fred

```

List all files which opened by specific command:

```
lsof -c mysqld

```

List all process which using a specific file:

```
lsof /var/run/mysqld/mysqld.sock

```

List all processes which opens files under specific directory:

```
lsof +d /etc/passwd

```

List all the open files used by a specific process with process id:

```
lsof -p 8729
```
