So how do you find Linux / UNIX system last reboot or shutdown date and time? The last utility will either list the sessions of specified users, ttys, and hosts, in reverse time order, or list the users logged in at a specified date and time. Each line of output contains the user name, the tty from which the session was conducted, any hostname, the start and stop times for the session, and the duration of the session.
who command
You need to use who command, to print who is logged on. It also displays the time of last system boot. Use last command to display system reboot and shutdown date and time.
$ who –b
Output:
system boot Apr 30 15:08
Use last command to display listing of last logged in users and system last reboot time and date:
$ last reboot | less
Or better try:
$ last reboot | head -1
Output:
reboot system boot 2.6.15.4 Sun Apr 30 15:08 - 16:22 (01:13)
last command searches back through the file /var/log/wtmp and displays a list of all users logged in (and out) since that file was created. The pseudo user reboot logs in each time the system is rebooted. Thus last reboot command will show a log of all reboots since the log file was created.
To display last shutdown date and time use following command:
$ last -x|grep shutdown | head -1
Output:
shutdown system down 2.6.15.4 Sun Apr 30 13:31 - 15:08 (01:37)
Where,
- -x: Display the system shutdown entries and run level changes.
For more information read last command man page.
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 13 comments… read them below or add one }
On my FC5 system instead of
last reboot | head -1
I can type
last reboot -1
i couldn’t find out the error. please help me.
#Send list of users logged on to server via email
59 11 * * * last | grep date ‘+%a %b %d’ > /tmp/users.out ; mail -s “Users Logged Today” ephrondiana@gmail.com
when i tried to execute,
$ last |grep date ‘+%a %b %d’
i got no such file or directory error.
Should be..
thanks a lot vivek.i din’t expect this much fast reply.But unfortunately when i execute,
$ last | grep $(date ‘+%a %b %d’)
i couldn’t get anything.Please help
My bad…I forgot to include double quote …
Also you may wanna try out:
HTH
Thanks vivek.its working great…..
the command “last reboot” worked for me, on my mac!
Can we find who rebooted the linux box?
In order to track who rebooted a linux machine, I would:
- disable root logins; many users sharing root is bad
- create a list of sudoers, so only people listed there could shutdown / reboot / halt
- /var/log/messages would contain traces of who ran sudo shutdown -r now or such
Thanks a lot!
I help me!
wtmp is rotated by the system, so the last solution will stop working. I believe the most reliable solution is:
The uptime idea from Sam is nice but really that just returns the uptime (same as the uptime command) in date format.
last | grep USERNAME | grep tty | head -n 1 |awk -F ‘ ‘ ‘{print $7}’