How long has my Linux system been running?
uptime
If you want it in numerical form, it's the first number in /proc/uptime
(in seconds), so the time of the last reboot is
date -d "$(</proc/uptime awk '{print $1}') seconds ago"
The uptime includes the time spent in a low-power state (standby, suspension or hibernation).
You can use uptime
or last
To see only the last time
last reboot -F | head -1 | awk '{print $5,$6,$7,$8,$9}'
more generically
last reboot
Note and warning
The pseudo user reboot logs in each time the system is rebooted.
Thus last reboot will show a log of all reboots since the log file was created.
I usually use who -b
, which produces output such as:
$ who -b
system boot 2014-05-06 22:47
$
It tells me the date and time when the machine was last booted, rather than the time that has elapsed since it was last booted.
This command works on many other Unix systems too (Solaris, …).