last is the command that you can make use of the get details of last login or reboots for users and ttys on a Unix or Linux distributions.
Example on macOS:% last
code2care ttys001 Mon Nov 7 17:02 still logged in
code2care ttys001 Mon Nov 7 16:04 - 16:04 (00:00)
code2care console Mon Nov 7 11:38 still logged in
reboot ~ Mon Nov 7 11:36
code2care ttys000 Sat Nov 5 16:08 - 16:08 (00:00)
code2care console Thu Nov 3 11:33 - 23:41 (3+12:08)
reboot ~ Thu Nov 3 11:31
code2care ttys001 Wed Nov 2 18:13 - 18:13 (00:00)
code2care console Tue Nov 1 11:05 - 01:09 (1+14:04)
reboot ~ Tue Nov 1 11:02
shutdown ~ Tue Nov 1 01:07
code2care ttys002 Mon Oct 31 19:10 - 19:10 (00:00)
wtmp begins Fri Oct 21 16:08
Command to know a specific user details
To find details for a specific user, you can pass in the username as a parameter,
Example on Ubuntu Linux Server:# last root
last code2care
root ttys001 Mon Nov 7 17:02 still logged in
root ttys001 Mon Nov 7 16:04 - 16:04 (00:00)
root ttys000 Mon Nov 7 13:02 still logged in
root ttys001 Mon Nov 7 12:56 - 12:56 (00:00)
root ttys000 Mon Nov 7 11:46 - 11:46 (00:00)
root console Mon Nov 7 11:38 still logged in
root ttys000 Sat Nov 5 16:08 - 16:08 (00:00)
wtmp begins Fri Oct 21 16:08
Command to know Last reboot times
# last reboot
reboot ~ Mon Nov 7 11:36
reboot ~ Thu Nov 3 11:31
reboot ~ Tue Nov 1 11:02
reboot ~ Thu Oct 27 11:29
reboot ~ Mon Oct 24 10:29
reboot ~ Fri Oct 21 16:08
![Last Login or Reboot details command Last Login or Reboot details command](https://code2care.org/q/command-to-check-last-login-or-reboot-history-of-users-and-ttys/images/Last Login or Reboot details command.jpg)
Facing issues? Have Questions? Post them here! I am happy to answer!
Author Info:
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
More Posts related to Linux,
- Command to know the Available Memory on Linux System
- How to install curl on Alpine Linux
- How to backup a file in Linux/Unix
- Install Java Runtime Environment (Oracle or open JRE) on Ubuntu
- What is the Default Admin user and Password for Jenkins
- How to tar.gz a directory or folder Command
- Copy entire directory using Terminal Command [Linux, Mac, Bash]
- Fix: bash: ipconfig: command not found on Linux
- Command to check Last Login or Reboot History of Users and TTYs
- Linux: Create a New User and Password and Login Example
- ls command to list only directories
- bash: cls: command not found
- How to exit from nano command
- Installing and using unzip Command to unzip a zip file using Terminal
- What does apt-get update command does?
- ls command: sort files by name alphabetically A-Z or Z-A [Linux/Unix/macOS/Bash]
- How to remove or uninstall Java from Ubuntu using apt-get
- scp: ssh: connect to host xxxx port 22: Connection refused Error
- Sort ls command by last modified date and time
- Create Nested Directories using mkdir Command
- How to Exit a File in Terminal (Bash/Zsh)
- Command to know the installed Debian version?
- How to connect to SSH port other than default 22
- How to save a file in Nano Editor and Exit
- Install OpenSSL on Linux/Ubuntu
More Posts:
- How to restore closed file in Notepad++ - NotepadPlusPlus
- Java Code to check if Twitter app is installed on Android device - Android
- ZSH: exec format error eclipse M1/M2 Mac - zsh
- How to set Connection and Max Timeout for cURL Request with Examples - cURL
- Github: fatal: Authentication failed Support for password was removed on August 13, 2021 - Git
- Transfer files between Android and Mac OS X using usb cable - Mac-OS-X
- How to Display content of a file in Terminal Screen? - Linux
- Program 2: Print your name using print() function - 1000+ Python Programs - Python-Programs