lastlog: command not found

The lastlog command is similar to the last command, but instead of listing the most recent login events, it lists all users and the last time they logged in. This command retrieves information from the /var/log/lastlog file.

lastlog Command Options

Option Description
-t n Print only logins more recent than n days ago.
-u name Print only login information for user name.

If you encounter the below error while running the lastlog command:

lastlog: command not found

you may try installing the below package as per your choice of distribution:

OS Distribution Command
Debian apt-get install login
Ubuntu apt-get install login
Alpine apk add shadow
Arch Linux pacman -S shadow
Kali Linux apt-get install login
Fedora dnf install shadow-utils
Raspbian apt-get install login

lastlog Command Examples

1. To print the last login of all the users:

# lastlog 

2. To print the records of specified days older:

# lastlog -b 10
# lastlog --before 10 

3. To print the logs more recent that specified days:

# lastlog -t 20
# lastlog --time 20 

4. To print the last login records of specified login:

# lastlog -u mike
# lastlog --user mike 

5. To display the help for lastlog:

# lastlog --help
Note: lastlog reads from /var/log/lastlog and lists the most recent login for each account.
Related Post