Ejemplos del comando PS

Ejemplos del comando PS.

El comando ps nos proporciona información sobre los procesos de un sistema Linux o Unix.

Debemos recordar que las aplicaciones se ejecutan como procesos en el sistema, y cada paquete instalado, puede requerir de uno o más procesos.

Podemos averiguar todo sobre los procesos que se ejecutan en nuestro sistema haciendo uso del comando ps.

Comenzamos.

 

Ejemplos del comando PS

ps -ef

Información sobre todos los procesos en el sistema.

ejemplo de salida…

UID PID PPID C STIME TTY TIME CMD
root 1 0 0 nov01 ? 00:02:54 /usr/lib/systemd/systemd –switched-root –system –deserialize 22
root 2 0 0 nov01 ? 00:00:00 [kthreadd]
root 3 2 0 nov01 ? 00:00:02 [ksoftirqd/0]
root 5 2 0 nov01 ? 00:00:00 [kworker/0:0H]
root 7 2 0 nov01 ? 00:00:00 [migration/0]
root 8 2 0 nov01 ? 00:00:00 [rcu_bh]
root 9 2 0 nov01 ? 00:04:07 [rcu_sched]
root 10 2 0 nov01 ? 00:00:00 [lru-add-drain]
root 11 2 0 nov01 ? 00:00:01 [watchdog/0]
root 12 2 0 nov01 ? 00:00:01 [watchdog/1]
root 13 2 0 nov01 ? 00:00:03 [migration/1]

 

ps -eF

Aplicando la opción “-F” veremos formatos extra.

ejemplo de salida…

UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
root 1 0 0 47851 4328 1 nov01 ? 00:02:54 /usr/lib/systemd/systemd –switched-root –system –deserializ
root 2 0 0 0 0 0 nov01 ? 00:00:00 [kthreadd]
root 3 2 0 0 0 0 nov01 ? 00:00:02 [ksoftirqd/0]
root 5 2 0 0 0 0 nov01 ? 00:00:00 [kworker/0:0H]
root 7 2 0 0 0 0 nov01 ? 00:00:00 [migration/0]
root 8 2 0 0 0 2 nov01 ? 00:00:00 [rcu_bh]
root 9 2 0 0 0 6 nov01 ? 00:04:07 [rcu_sched]
root 10 2 0 0 0 0 nov01 ? 00:00:00 [lru-add-drain]
root 11 2 0 0 0 0 nov01 ? 00:00:01 [watchdog/0]
root 12 2 0 0 0 1 nov01 ? 00:00:01 [watchdog/1]
root 13 2 0 0 0 1 nov01 ? 00:00:03 [migration/1]

 

ps -eLF

Obtener información sobre los hilos.

ejemplo de salida…

UID PID PPID LWP C NLWP SZ RSS PSR STIME TTY TIME CMD
root 1 0 1 0 1 47851 4328 4 nov01 ? 00:02:54 /usr/lib/systemd/systemd –switched-root –system –
root 2 0 2 0 1 0 0 0 nov01 ? 00:00:00 [kthreadd]
root 3 2 3 0 1 0 0 0 nov01 ? 00:00:02 [ksoftirqd/0]
root 5 2 5 0 1 0 0 0 nov01 ? 00:00:00 [kworker/0:0H]
root 7 2 7 0 1 0 0 0 nov01 ? 00:00:00 [migration/0]
root 8 2 8 0 1 0 0 2 nov01 ? 00:00:00 [rcu_bh]
root 9 2 9 0 1 0 0 7 nov01 ? 00:04:07 [rcu_sched]
root 10 2 10 0 1 0 0 0 nov01 ? 00:00:00 [lru-add-drain]
root 11 2 11 0 1 0 0 0 nov01 ? 00:00:01 [watchdog/0]
root 12 2 12 0 1 0 0 1 nov01 ? 00:00:01 [watchdog/1]
root 13 2 13 0 1 0 0 1 nov01 ? 00:00:03 [migration/1]

 

ps -p pidlist

Listar los procesos que quieras, por ejemplo…

ejemplo de salida…

UID PID PPID C STIME TTY TIME CMD
user1 1853 1742 0 08:42 ? 00:00:08 /usr/bin/ibus-daemon –daemonize –xim
user1 1941 1742 0 08:42 ? 00:00:00 /usr/bin/pulseaudio –start –log-target=syslog
user1 3542 2445 8 12:41 ? 00:00:28 /opt/google/chrome/chrome –type=renderer –enable-deferred-image-decoding –lang=en-US –force-fieldt

 

Personalizar la salida de PS

En el ejemplo usamos lo siguiente:

ejemplo de salida…

USER PID PPID NLWP %CPU %MEM PSR START TT TIME COMMAND
root 1 0 1 0.0 0.0 3 nov01 ? 00:02:54 /usr/lib/systemd/systemd –switched-root –system –deserializ
root 2 0 1 0.0 0.0 0 nov01 ? 00:00:00 [kthreadd]
root 3 2 1 0.0 0.0 0 nov01 ? 00:00:02 [ksoftirqd/0]
root 5 2 1 0.0 0.0 0 nov01 ? 00:00:00 [kworker/0:0H]
root 7 2 1 0.0 0.0 0 nov01 ? 00:00:00 [migration/0]
root 8 2 1 0.0 0.0 2 nov01 ? 00:00:00 [rcu_bh]
root 9 2 1 0.0 0.0 6 nov01 ? 00:04:07 [rcu_sched]
root 10 2 1 0.0 0.0 0 nov01 ? 00:00:00 [lru-add-drain]
root 11 2 1 0.0 0.0 0 nov01 ? 00:00:01 [watchdog/0]
root 12 2 1 0.0 0.0 1 nov01 ? 00:00:01 [watchdog/1]
root 13 2 1 0.0 0.0 1 nov01 ? 00:00:03 [migration/1]

Otro ejemplo, pero por hilo:

ejemplo de salida…

USER PID PPID NLWP LWP %CPU %MEM PSR START TT TIME COMMAND
root 1 0 1 1 0.0 0.0 6 nov01 ? 00:02:54 /usr/lib/systemd/systemd –switched-root –system –dese
root 2 0 1 2 0.0 0.0 0 nov01 ? 00:00:00 [kthreadd]
root 3 2 1 3 0.0 0.0 0 nov01 ? 00:00:02 [ksoftirqd/0]
root 5 2 1 5 0.0 0.0 0 nov01 ? 00:00:00 [kworker/0:0H]
root 7 2 1 7 0.0 0.0 0 nov01 ? 00:00:00 [migration/0]
root 8 2 1 8 0.0 0.0 2 nov01 ? 00:00:00 [rcu_bh]
root 9 2 1 9 0.0 0.0 4 nov01 ? 00:04:08 [rcu_sched]
root 10 2 1 10 0.0 0.0 0 nov01 ? 00:00:00 [lru-add-drain]
root 11 2 1 11 0.0 0.0 0 nov01 ? 00:00:01 [watchdog/0]
root 12 2 1 12 0.0 0.0 1 nov01 ? 00:00:01 [watchdog/1]
root 13 2 1 13 0.0 0.0 1 nov01 ? 00:00:03 [migration/1]

 

Ordenamos la salida

ejemplo de salida…

USER PID PPID NLWP %CPU %MEM PSR START TT TIME COMMAND
mysql 1566 1 44 0.4 3.7 1 nov01 ? 00:30:23 /usr/sbin/mysqld
root 1240 1 21 0.2 0.1 4 nov01 ? 00:15:12 /usr/bin/python /usr/bin/fail2ban-server -s /var/run/fail2ban/
root 6359 6357 1 0.1 0.1 5 11:50 ? 00:00:00 /usr/bin/sw-engine -c /usr/local/psa/admin/conf/php.ini -dauto
root 1055 1 16 0.1 0.1 1 nov01 ? 00:11:20 /usr/bin/dockerd
nginx 24031 24030 1 0.1 0.0 0 nov05 ? 00:01:13 nginx: worker process
root 24304 1 1 0.1 0.0 4 nov05 ? 00:01:28 /bin/sh /usr/local/ddos/ddos.sh -l
drweb 2891 1 1 0.0 2.4 0 nov01 ? 00:00:27 /opt/drweb/drwebd.real –foreground=yes
drweb 28710 2891 1 0.0 2.4 4 11:16 ? 00:00:00 /opt/drweb/drwebd.real –foreground=yes
named 1099 1 5 0.0 0.9 3 nov01 ? 00:00:37 /usr/sbin/named -u named -t /var/named/chroot -c /etc/named.co
popuser 19727 19725 1 0.0 0.4 0 03:30 ? 00:00:03 spamd child
apache 24071 24065 27 0.0 0.3 2 nov05 ? 00:00:46 /usr/sbin/httpd -DFOREGROUND

 

Saltar encabezados

Si creamos un script o cualquier herramienta (ejemplo) que nos proporcione exclusivamente cierta información, y evidentemente sin los encabezados.

ejemplo de salida…

userX 7705 00:00:00 php-fpm:
mysql 1566 00:30:23 /usr/sbin/mysqld
root 1240 00:15:13 /usr/bin/python
root 1055 00:11:20 /usr/bin/dockerd
postfix 7750 00:00:00 smtpd

 

Espero te sean útiles estos ejemplos del comando ps.

 

Ejemplos del comando PS
5 (100%) 2 Votos

Agregar comentario

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.