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.
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:
Option | Description |
---|---|
-s | Shows the date/time since the system has been up. |
-p | Prints the output in pretty format. |
-v | Displays the command version info. |
-h | Shows 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
The output shows:
09:06:29
- The time whenuptime
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
Show Uptime in Pretty Format
Run the command with -p
to print system uptime in a pretty, or more user-friendly, format.
uptime -p
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
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
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
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
The first output line is identical to the uptime
output and includes the following:
12:15:48
- The time whenw
was executed.up 1 day, 8:37
- The system uptime1 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
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
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.