Who's logging into your Linux servers?

To see how long currently logged in users have been logged in, you can use the last command.

$ last shs
shs      pts/3        192.168.0.11     Tue Apr  5 08:24   still logged in

The w command will show you when current users logged in and how long they’ve been idle.

$ w
 17:03:53 up  6:02,  3 users,  load average: 0.24, 0.23, 0.20
USER     TTY        LOGIN@   IDLE   JCPU   PCPU WHAT
fedora   seat0     11:02    0.00s  0.00s  0.00s /usr/libexec/gdm-wayland-session /usr/bin/gnome-session
fedora   tty2      11:02    6:02m  0.06s  0.06s /usr/libexec/gnome-session-binary
shs      pts/3     16:24    0.00s  0.13s  0.02s w

The load averages shown on the first line of output above are measurements of the computational work the system is performing. Ideally, these should all be less than the number of CPUs on the system. Higher numbers represent a problem or an overloaded machine.

The ac -p command can show how long users have been logged in as a number of hours.

$ ac -p
        lola                                 5.43
        shs                                  9.88
        total        15.31

If you manage Linux servers, it’s a good idea to understand how much they’re being used and which users are making the heaviest use of them. Your busiest servers may require more monitoring and more communication with your user base.



Source link