The Linux uptime command is part of the GNU Core Utilities package. Therefore, it is available on almost any Linux distribution. This simple command allows you to see how long a system has been running, along with other important information. In this article, we will see how to use the uptime command in Linux, explain it's output, and some of it's command-line options.

Basic Uptime Usage

The uptime command returns a single line of information that includes the current time, system running time, number of users logged in, and the system load averages.  It fetches the current logged in users from /var/tmp/utmp and the systems running process information from /proc.

The uptime command when used without any options, displays the following information in a single line:

  • Current time
  • Uptime
  • Number of users currently logged into
  • System load averages
kbuzdar@putor:~$ uptime
 09:24:46 up  4:34,  1 user,  load average: 0.46, 0.37, 0.27 

Let’s break down the output to better understand it.

Current time (in hh:mm:ss): The first column in the uptime output is the current systems time. In this example it is 09:24:46.

Uptime (in hh:mm): It is the amount of time during which the system last booted. In our example, you will see the uptime value as 4:34 which means the system has been up for 4 hours and 34 minutes.

Number of Logged in Users: “1 user” in the example output shows that only 1 user is currently logged in to the system.

Load Average: It is the average system load for the past 1, 5, and 15 minutes. In the above output:

  • Load average over the last 1 minute is 0.46
  • Load average over the last 5 minutes is 0.37
  • Load average over the last 15 minutes is 0.27

Uptime Command Options

The uptime command has only a few options. Let's take a look at the more commonly used options.

Display uptime Output in Pretty (Human Friendly) Format

When no option is specified, the uptime command displays the uptime in the hh:mm format along with other information. By using the uptime command with -p or --pretty option, it displays only the uptime information and in a more human friendly format.

kbuzdar@putor:~$ uptime -p
up 4 hours, 35 minutes

Display Start Time of System

We can use the uptime command with -s or --since option to display the time since the systems last boot.

kbuzdar@putor:~$ uptime -s
2020-06-03 04:49:50 

The above output shows the date and time of the last system boot.

Showing uptime Version

As with many other commands you can use -V or --version to show which version of the uptime utility you are using.

kbuzdar@putor:~$ uptime -V
uptime from procps-ng 3.3.15

Conclusion

In this article, we have dicussed how to use the uptime command in Linux and explained it's output. It is a useful command that shows how long your system has been running. It is one of those simple commands that System Administrators use often.

Resources