Two useful Linux commands

I came across a couple of Linux commands that I have not used before and wanted to share them in case anyone else find them useful. I used them to determin who was on a linux server as well as when the server last rebooted for troubleshooting a web server problem.

The command are 
last
From the man page:

NAME
       last, lastb - show listing of last logged in users

SYNOPSIS
       last  [-R] [-num] [ -n num ] [-adFiowx] [ -f file ] [ -t YYYYMMDDHHMMSS
       ] [name...]  [tty...]
       lastb [-R] [-num] [ -n num ] [ -f file ] [-adFiowx] [name...]  [tty...]

DESCRIPTION
       Last searches back through the file /var/log/wtmp (or the  file  desig‐
       nated  by  the -f flag) and displays a list of all users logged in (and
       out) since that file was created.  Names of  users  and  tty's  can  be
       given,  in  which  case  last will show only those entries matching the
       arguments.  Names of ttys can be abbreviated, thus last 0 is  the  same
       as last tty0.



The other is a variation of the first and shows a list of reboots on the pc or server.

last reboot
From the man page:
      The pseudo user reboot logs in each time the system is rebooted.   Thus
       last  reboot will show a log of all reboots since the log file was cre‐
       ated.



Hope this helps.


Labels: , ,