aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/monitor/lsof.md
blob: 82530031a5a0911ad637599da2b0b3e32492b36e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# lsof(8)

```markdown
lsof
  -a ......... AND slection filters instead ORing (OR: default)
  -p <pid> ... filter by <pid>
  +fg ........ show file flags for file descripros
  -n ......... don't convert network addr to hostnames
  -P ......... don't convert network port to service names
  -i <@h[:p]>. show connections to h (hostname|ip addr) with optional port p
```

```markdown
file flags:
  R/W/RW ..... read/write/read-write
  CR ......... create
  AP ......... append
  TR ......... truncate
```

# Examples

## File flags
Show open files with file flags for process:
```markdown
lsof +fg -p <pid>
```
## Open TCP connections
Show open tcp connections for `$USER`:
```markdown
lsof -a -u $USER -i tcp
```
**Note**: `-a` _ands_ the results. If `-a` is not given all open files matching
`$USER` and all tcp connections are listed (_ored_).

## Open connection to specific host
Show open connections to `localhost` for `$USER`:
```markdown
lsof -a -u $USER -i @localhost
```