Página 1 de 1

Comando para saber quién está logueado y qué está haciendo: comando w

Publicado: 21 Jun 2024, 13:46
por gbeltran
Para saber quíen está logueado en la máquina y qué está haciendo, utiliza el comando w.
Ejemplo:

Código: Seleccionar todo

guillermo@maquina:~$ w
 13:39:59 up  6:00,  5 users,  load average: 0,17, 0,27, 0,31
USER     TTY      DESDE            LOGIN@   IDLE   JCPU   PCPU WHAT
guillerm :0       :0               09:03   ?xdm?   7:37    ?    /usr/libexec/gdm-x-session --register-session --run-script startxfce4
guillerm pts/1    :pts/0:S.0       13:23    3.00s  0.03s  0.02s w
guillerm pts/0    127.0.0.1  10:54    3.00s  0.07s   ?    screen (NOTA: LA IP LA HE CAMBIADO)
testing  :1       :1               13:10   ?xdm?   7:37   0.01s /usr/libexec/gdm-x-session --register-session --run-script /usr/libexec
guillerm tty6     -                13:21   18:30   0.10s  0.01s -bash
En el anterior ejemplo, podemos ver que al usuario guillerm (en realidad es guillermo, pero no se muestran más caracteres) está logueado en la misma máquina con 4 sesiones distintas en cuatro terminales (TTY) o consolas, y el usuario testing con una. Linux tiene la capacidad de utilizar varias sesiones de terminales pulsando las teclas Ctrl + Alt + F1 hasta F7. Eso sí, solo puede haber activa una sesión gráfica. Por defecto, si no has iniciado la sesión gráfica en ninguna de las consolas, accederás a ella con Crtl +Alt + F7.

- Man w (manual del comando w):
DESCRIPTION
w displays information about the users currently on the machine, and their processes. The header shows, in this order, the
current time, how long the system has been running, how many users are currently logged on, and the system load averages for
the past 1, 5, and 15 minutes.

The following entries are displayed for each user: login name, the tty name, the remote host, login time, idle time, JCPU,
PCPU, and the command line of their current process.

The JCPU time is the time used by all processes attached to the tty. It does not include past background jobs, but does in‐
clude currently running background jobs.

The PCPU time is the time used by the current process, named in the "what" field.

COMMAND-LINE OPTIONS
-h, --no-header
Don't print the header.

-u, --no-current
Ignores the username while figuring out the current process and cpu times. To demonstrate this, do a su and do a w
and a w -u.

-s, --short
Use the short format. Don't print the login time, JCPU or PCPU times.

-f, --from
Toggle printing the from (remote hostname) field. The default as released is for the from field to not be printed,
although your system administrator or distribution maintainer may have compiled a version in which the from field is
shown by default.

--help Display help text and exit.

-i, --ip-addr
Display IP address instead of hostname for from field.

-V, --version
Display version information.

-o, --old-style
Old style output. Prints blank space for idle times less than one minute.

user Show information about the specified user only.

ENVIRONMENT
PROCPS_USERLEN
Override the default width of the username column. Defaults to 8.

Re: Comando para saber quién está logueado y qué está haciendo: comando w

Publicado: 21 Jun 2024, 13:49
por gbeltran

Re: Comando para saber quién está logueado y qué está haciendo: comando w

Publicado: 21 Jun 2024, 13:53
por gbeltran