Linux Uptime Command

November 7, 2023

Introduction

The Linux uptime command shows the system's uptime, how long it has been running, and when it was last booted. Depending on the options, the command prints the number of users and system load averages.

This tutorial explains the uptime command options and elaborates on alternative ways to read the system's uptime.

Linux uptime command

Prerequisites

  • A Linux system (this tutorial uses Ubuntu 22.04).
  • Access to the terminal.

Linux uptime Syntax

The uptime syntax is:

uptime [options]

The command prints system uptime output when executed without any arguments. However, using different options modifies uptime and prints filtered output.

Linux uptime Options

The uptime command works with different options. Common ones are in the table below:

OptionDescription
-sShows the date/time since the system has been up.
-pPrints the output in pretty format.
-vDisplays the command version info.
-hShows a help message about the command options and usage.

Linux uptime Command Examples

The uptime command shows how long the system has remained active. The following text presents common use case examples.

Print System Uptime

Run the command without any arguments to print system uptime and load averages.

uptime
uptime terminal output

The output shows:

  • 09:06:29 - The time when uptime was executed.
  • up 1 day, 5 hours, 28 minutes - The system uptime that shows the system has been up and running for one day, five hours, and 28 minutes.
  • 1 user - The number of users currently logged into the system.
  • load average: 0.00, 0.00, 0.00 - The system load averages for the last one, five, and 15 minutes.

Note: This command only lists the number of currently logged-in users. To learn more about the users that are logged in, use the who command or w command.
To get information about all users, regardless of login status, refer to our guide on how to list users in Linux.

Print the Exact System Uptime

To show the exact date and time when the system was booted, run uptime with the -s option:

uptime -s
uptime -s terminal output

Show Uptime in Pretty Format

Run the command with -p to print system uptime in a pretty, or more user-friendly, format.

uptime -p
uptime -p terminal output

The output shows how long the system has been running without any additional information.

Print the Uptime Version

Run uptime with -V to show the version installed on the machine.

uptime -V
uptime -V terminal output

In our case, the uptime tool version is 3.3.17

Get Help Information for Uptime

To display the help message and get additional info about the command, run the following:

uptime -h
uptime -h terminal output

Linux uptime Alternatives

Linux uptime is not the only command that prints info about the system uptime. The following text presents uptime alternatives.

/proc/uptime

The uptime command uses the /proc/uptime file to calculate the output. The /proc/uptime file is located in the /proc directory, a filesystem that is generated when the system boots. It is dynamically updated to reflect the current state of the system. To access the file, open it in the text editor of choice or run cat:

cat /proc/uptime
cat /proc/uptime terminal output

The output shows the system uptime and system idle time in seconds. This process is less user-friendly but more accurate than the uptime output.

w Command

Another way to get the system uptime info is with the w command. The w command prints info about currently logged-in users, including the login time, uptime, and load averages.

Test the command by running:

w
w terminal output

The first output line is identical to the uptime output and includes the following:

  • 12:15:48 - The time when w was executed.
  • up 1 day, 8:37 - The system uptime
  • 1 user - The number of users currently logged into the system.
  • load average: 0.15, 0.03, 0.01 - The system load averages for the last one, five, and 15 minutes.

Among other details, the third output line includes the system idle time, which is three days.

top Command

Another way to see the system uptime is by looking at the first line of the top command output. Execute the following:

top
top terminal output

The header top line shows the same info as uptime or w commands: the time when the command was executed, uptime, number of users, and load averages.

who Command

The who command with the -b option shows the date and time the system was last booted. To test the command, enter:

who -b
who -b terminal output

Conclusion

After reading this article, you learned how to use the Linux uptime command and other ways to check the system's uptime.

Next, check out the Linux command cheat sheet for information about other important Linux commands.

Was this article helpful?
YesNo
Sara Zivanov
Sara Zivanov is a technical writer at phoenixNAP who is passionate about making high-tech concepts accessible to everyone. Her experience as a content writer and her background in Engineering and Project Management allows her to streamline complex processes and make them user-friendly through her content.
Next you should read
How to Check Memory Usage in Linux, 5 Simple Commands
March 28, 2024

In this tutorial, learn the five most commonly used commands to check memory usage in Linux. We also provide with detailed explanations of what they do and more...
Read more
What Is Load Balancing? Definition and How It Works
June 30, 2021

Load balancing is a method for distributing network traffic across multiple servers in a pool, that way improving performance and preventing bottlenecks. This...
Read more
How to Check CPU Utilization in Linux with Command Line
March 6, 2024

You have probably noticed your Linux OS slowing down, especially when working harder. Understanding CPU processor usage is critical for overall performance measurement...
Read more
How to List Running Processes in Linux
September 2, 2021

As a system administrator, you will need to manage processes. Managing running processes is an important part of Linux administration. This tutorial shows different methods you can use to list running processes in Linux...
Read more