Sometimes, you might need to know for how long your system has been running. In this guide, you will learn how to check uptime for a Linux server. There are various ways of accomplishing this using various tools. Without much further ado, let’s begin.
Prerequisites
To get started, you need to have an instance of a Linux server. If you don’t have a physical server, you can deploy a fully managed Cloud VPS starting at $4.20 a month. Any Linux distribution will do as the commands we are running are universal.
Without much further ado, let’s get started.
1) Check uptime for a server using the uptime command
Let’s begin with the simple uptime command.
$ uptime
It prints on the terminal the last time when the system was booted, the uptime in HH:mm format, and the load average. Here’s a good example of the sample output.
If you want to display the last time since the system has been up, append the -s
flag.
$ uptime -s
To view the uptime in a more user-friendly and human-readable format, append the -p
flag.
$ uptime -p
2) Check uptime using the w command
The w command is yet another command-line tool that you can use to derive uptime. Usually, it’s used to check logged in users, but along with that, it also displays uptime statistics.
Simply run the command as follows.
$ w
3) Check uptime for a Linux server using neofetch utility
Neofetch is a command-line tool that displays a flurry of system information on a terminal including the OS logo. It checks the Linux version alongside information such as OS type, kernel, Shell type, CPU and memory information, and even uptime.
To launch neofetch, simply run:
$ neofetch
4) Check uptime using top / htop utilities
The Linux top command is used to check currently running processes on a system. However, you can retrieve other information from the top section of the output such as load average, memory size, CPU utilization, and uptime.
$ top
Htop is an improved version of the top utility, It displays colored output in a user-friendly manner. Checking uptime is made much simpler in comparison to using the top command.
$ htop
That closes the curtain on today’s topic. We have outlined 4 ways that you can use to display your system’s uptime.