• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

lastlog: command not found

by admin

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.

Filed Under: Linux

Some more articles you might also be interested in …

  1. CentOS / RHEL : How to find which user run a specific command?
  2. How to use rndc command (command-line administration tool for named)
  3. macchanger: command not found
  4. i3exit Command Examples in Linux
  5. flatpak-builder Command Examples in Linux
  6. binwalk Command Examples in Linux
  7. cgcreate: command not found
  8. RHEL / CentOS : How to shrink LVM volume
  9. isosize: command not found
  10. How to change a system’s machine-ID in Oracle Enterprise Linux 7

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright