Difference between revisions of "Lsof"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
 
Line 1: Line 1:
[[lsof]] is a [[command]] to list open files on your system. This can help you to find out which application is blocking your sound card so it does not play or your CD ROM drive so it does not eject. It is also possible to show processes that have a [[network]] socket open.
+
[[lsof]] is a [[command]] to list open files on your system. Files can be normal files, pipes, sockets and device files. This can help you to find out which application is blocking your CD ROM drive so it does not eject. It is also possible to show processes that have a [[network]] socket open using lsof -i.
  
 
= Examples =
 
= Examples =
Line 21: Line 21:
 
* [http://www.manpagez.com/man/8/lsof/ man page]
 
* [http://www.manpagez.com/man/8/lsof/ man page]
 
* [[strace]]
 
* [[strace]]
* [[netstat]]
+
* [[netstat]] - similar to lsof -i
 
* [[nmap]]
 
* [[nmap]]
 
* [[telnet]]
 
* [[telnet]]

Latest revision as of 15:19, 4 April 2015

lsof is a command to list open files on your system. Files can be normal files, pipes, sockets and device files. This can help you to find out which application is blocking your CD ROM drive so it does not eject. It is also possible to show processes that have a network socket open using lsof -i.

Examples

  • Show which process is blocking your soundcard:
lsof | grep dsp
  • Show which process listens on your smtp port
tweedleburg:~/Downloads # lsof -i | grep smtp
master     3320   root   12u  IPv4   9503      0t0  TCP localhost:smtp (LISTEN)
master     3320   root   13u  IPv6   9505      0t0  TCP localhost:smtp (LISTEN)

Headings

# lsof +c 15
COMMAND          PID  TID       USER   FD      TYPE     DEVICE SIZE/OFF       NODE NAME
[...]
speaker-test    3156            root    5r     FIFO        0,8      0t0      19532 pipe
speaker-test    3156            root    6w     FIFO        0,8      0t0      19532 pipe
threaded-ml     3156 3157       root    5r     FIFO        0,8      0t0      19532 pipe
threaded-ml     3156 3157       root    6w     FIFO        0,8      0t0      19532 pipe

See also