To find out how long a Linux system has been running, you can use the uptime
command. This command displays the current time, the amount of time the system has been running, and the load averages for the past 1, 5, and 15 minutes.
For example:
$ uptime 22:10:01 up 4:19, 2 users, load average: 0.10, 0.07, 0.03
In this example, the system has been running for 4 hours and 19 minutes (up 4:19
).
You can also use the who
command to view the system's boot time. The who
command displays information about users currently logged into the system, including the system's boot time.
For example:
$ who -b system boot 2022-12-18 22:06
In this example, the system was last booted on December 18th at 22:06.
Keep in mind that the uptime
command only shows the amount of time the system has been running since the last boot. If the system has been restarted or powered off and on, the uptime will reset to zero. To find out the total amount of time the system has been running since it was installed, you will need to track the boot times manually or use a tool that can do this for you.