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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

lastlog Command Examples in Linux

by admin

lastlog command prints the last login times for system accounts. Login information is read from the file /var/log/lastlog.

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.

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. uptime Command Examples in Linux
  2. “az feedback”: Send feedback to the Azure CLI Team
  3. kustomize Command Examples
  4. “git extras” Command Examples
  5. linkchecker Command Examples
  6. What is Anacron and usage of Anacron in Linux
  7. trash Command Examples in Linux
  8. Using grep to search in reverse
  9. How to Audit File Access on Linux
  10. kill: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright