Fecha de última modificación:

6 Abril, 2014 - 04:54

lsof

Lista ficheros abiertos. Este comando también se utiliza para la detección de intrusión.

lsof -c [proceso] lista los ficheros abiertos por un proceso.

lsof +D [Directorio] lista los procesos que están usando el directorio.

lsof -i muestra todos los ficheros de red utilizados por procesos de red.

lsof -i :60627 muestra los procesos que se encuentren detrás del puerto 60627

lsof -i tcp muestra todos los hilos tcp con su correspondientes programas ejecutado

lsof | awk '{ print $1 }' | sort | uniq -c | sort -nr averiguo cuantos ficheros tiene abiertos cada proceso.

Ejemplo de la salida del comando lsof -i tcp

# lsof -i tcp
COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
postgres 2545 postgres    3u  IPv6   9821      0t0  TCP localhost:postgresql (LISTEN)
postgres 2545 postgres    6u  IPv4   9822      0t0  TCP localhost:postgresql (LISTEN)
ruby     2903     root    7u  IPv6  13880      0t0  TCP localhost:42118->localhost:postgresql (ESTABLISHED)
ruby     2903     root    8u  IPv6  13886      0t0  TCP localhost:42119->localhost:postgresql (ESTABLISHED)
ruby     2903     root    9u  IPv6  13891      0t0  TCP localhost:42120->localhost:postgresql (ESTABLISHED)
ruby     2903     root   10u  IPv4  13898      0t0  TCP localhost:50505 (LISTEN)
ruby     2903     root   11u  IPv6  14681      0t0  TCP localhost:42121->localhost:postgresql (ESTABLISHED)
sshd     3097     root    3u  IPv4  12298      0t0  TCP *:ssh (LISTEN)
sshd     3097     root    4u  IPv6  12300      0t0  TCP *:ssh (LISTEN)
ruby     3112   daemon    6u  IPv6  12539      0t0  TCP localhost:42007->localhost:postgresql (ESTABLISHED)
ruby     3112   daemon   10u  IPv4  12782      0t0  TCP localhost:3001 (LISTEN)
postgres 3228 postgres    9u  IPv6  12540      0t0  TCP localhost:postgresql->localhost:42007 (ESTABLISHED)
sshd     3542     root    3u  IPv4  13659      0t0  TCP 192.168.1.8:ssh->192.168.1.4:6045 (ESTABLISHED)
sshd     3542     root    8u  IPv6  13857      0t0  TCP localhost:6010 (LISTEN)
sshd     3542     root    9u  IPv4  13858      0t0  TCP localhost:6010 (LISTEN)
nginx    3568     root    9u  IPv4  14526      0t0  TCP *:3790 (LISTEN)
nginx    3569   daemon    9u  IPv4  14526      0t0  TCP *:3790 (LISTEN)
nginx    3570   daemon    9u  IPv4  14526      0t0  TCP *:3790 (LISTEN)
nginx    3571   daemon    9u  IPv4  14526      0t0  TCP *:3790 (LISTEN)
nginx    3572   daemon    9u  IPv4  14526      0t0  TCP *:3790 (LISTEN)
postgres 3684 postgres    9u  IPv6  14655      0t0  TCP localhost:postgresql->localhost:42118 (ESTABLISHED)
postgres 3686 postgres    9u  IPv6  13887      0t0  TCP localhost:postgresql->localhost:42119 (ESTABLISHED)
postgres 3687 postgres    9u  IPv6  13892      0t0  TCP localhost:postgresql->localhost:42120 (ESTABLISHED)
postgres 3696 postgres    9u  IPv6  14682      0t0  TCP localhost:postgresql->localhost:42121 (ESTABLISHED)
ruby     3710   daemon    7u  IPv6  14723      0t0  TCP localhost:42123->localhost:postgresql (ESTABLISHED)
postgres 3717 postgres    9u  IPv6  13916      0t0  TCP localhost:postgresql->localhost:42123 (ESTABLISHED)

Ver también el comando fuser

Leer más sobre: 

¿Te resulto útil?: 

5

Comentarios

Hola Francisco.

Gracias por tu aporte, me ha sido de mucha utilidad.
Solo tengo una duda, a ver si puedes apoyarme con el LSOF.
Usando lsof hay forma de listar archivos .php que se esten ejecutando ?

Saludos.

Envíanos tús preguntas, comentarios o sugerencias

 

Solicita Asistencia

Llámenos al:+54-9-11-32788353

Envíenos un e-mail: consultas@ ---Para enviar el SPAM--- francisconi.org

Skype Status for francisconi.hugo.adrian
 

Suscríbete

Suscríbete y recibe las últimas actualizaciones, noticias y más ...
Zircon - This is a contributing Drupal Theme
Design by WeebPal.