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

-
Have Questions? Post them here!
More Posts related to Linux,
- [Fix] Linux - bash: useradd: command not found
- Calculate days between dates using dateutils ddiff command
- pwd Command - Print Working Directory
- Rename a directory using Linux/Unix command
- How to go to the End of File in Nano Editor
- How to tar.gz a directory or folder Command
- How to remove/delete a directory in Linux/macOs
- How to Display content of a file in Terminal Screen?
- ls command sort by file size [Linix/UNIX/macOS/bash]
- How to Copy Entire Directory to another Directory in Linux
- 3 ways to clear screen on Linux Terminal
- Command to check Last Login or Reboot History of Users and TTYs
- How to check uptime of Linux/Unix/macOS system/server using console command?
- How to backup a file in Linux/Unix
- Command to know the installed Debian version?
- Check SSH/OpenSSH version Command
- 3 Commands to stop Nginx Server
- Linux: Create a New User and Password and Login Example
- How to install npm on Ubuntu
- How to List All Users in Linux
- How to Get the List of Shells on Linux
- Fix - ssh-copy-id no identities found error
- Installing and using unzip Command to unzip a zip file using Terminal
- scp: ssh: connect to host xxxx port 22: Connection refused Error
- zsh hello world example
More Posts:
- JSON column formatting to preview SharePoint Online file on mouse hover - SharePoint
- Calculate Volume of Ellipsoid - C-Program
- Check macOS free disk space using Terminal command - MacOS
- Java JDBC Connection with Database using SSL (https) URL - Java
- How to get Client IP address using Java Code Example - Java
- Find Nearest Gas Station using Google Map App on your Phone - Google
- 7 Python Arithmetic Operators with Examples [Tutorial] - Python
- How to create alias in macOS - MacOS