While it may not appear beneficial for ordinary Linux users, keeping tabs on how long the system has been running and active is crucial for any system administrator. It’s one among several auditing roles that allows them to know how long the system has been up. In this guide, we discuss several ways that you can probe the Linux uptime. We have performed the procedure on Ubuntu 20.04 LTS.
Check uptime using the uptime command
The uptime command provides a bird’s eye view of the duration your system has been running. The command provides a wealth of information including the current system time, the logged-in user(s), and the load average.
Uptime Syntax
You can run the uptime command without any options with the following syntax:
$ uptime
It will display the following output:
As shown, the output displays the current system time, closely followed by the status of the system denoted by the parameter ‘up’. Thereafter, you are provided with the total time that the system has been up, followed by the number of logged-in users, and finally the system’s load average. From the output, we learn that the current time of the system is 16:25:07. It’s been up for the last 18 minutes with only 1 logged-in user. The load average is 0.00, 0.34, and 0.64.
Uptime pretty format
The -p option displays the results in ‘pretty format’ or in a more human-readable format. The output is provided in days, hours, and minutes. For our case, the system has only been up for 31 minutes.
$ uptime -p
Uptime starting time
The server’s starting time or the time from which it has been up and running can be displayed using the -s option. It will display the date and time since the server has been running.
$ uptime -s
From the output, the server has been running since 16:06:54 on the 16th May 2021.
Check uptime using the top command
While the good old top command is used for giving an overview of the currently running Linux processes, it also provides a dynamic view of real-time system statistics including the uptime. The uptime information is displayed at the very top as shown.
$ top
Conclusion
As you have seen, printing out the uptime is quite a breeze and with just a few commands – uptime & top – you can easily perform an audit of your system’s uptime.