Linux | Uptime command with examples
It is used to find out how long the system is active (running). This command returns set of values that involve, the current time, and the amount of time system is in running state, number of users currently logged into, and the load time for the past 1, 5 and 15 minutes respectively.
Linux uptime Syntax
uptime [-options]
Example:
Input
[mistersubha@server-1 ~]$uptime
08:24:37 up 207 days, 11:10, 0 users, load average: 0.00, 0.03, 0.05
Output

From the above code, the output has got four parts: Current time, Uptime, Number of Users, and average load, as mentioned earlier.
Linux uptime Options
Linux uptime as got few options to tailor outputs and to those who are unaware of the options of the newbies working with uptime can use the option "-h" (which means help). This will give the options available to the preceding command.
[mistersubha@server-1 ~]$uptime -h
Usage:
uptime [options]
Options:
-p, --pretty show uptime in pretty format
-h, --help display this help and exit
-s, --since system up since
-V, --version output version information and exit
For more details see uptime(1).

Just to make sure you get the uptime in human-readable format, you can use option
"p"
[mistersubha@server-1 ~]$uptime -p
up 29 weeks, 4 days, 11 hours, 1 minute

Option
"s"
is used to get the starting time/specified time when the system started has been running.
[mistersubha@server-1 ~]$uptime -s
2017-11-10 20:14:15

Version information can be shown using option
"V"
.
[mistersubha@server-1 ~]$uptime -V
uptime from procps-ng 3.3.10

There are few other ways to find the uptime and output header of command
"w"
is similar to that of output of
"uptime"
command.
Linux uptime Command Examples
The uptime
command in Linux provides information about how long the system has been running, along with the number of users and the system load averages. Here are some examples of using the uptime
command:
- Basic Usage: This shows the current time, how long the system has been up, the number of users currently logged in, and the load average over the last 1, 5, and 15 minutes.
uptime
- Using with
-p
Option: The-p
(pretty) option shows the uptime in a more human-readable format.
uptime -p
- Using with
-s
Option: The-s
(since) option displays the date and time when the system was last booted.
uptime -s
- Checking System Load Average: This command extracts and displays only the load averages for the last 1, 5, and 15 minutes using
awk
.
uptime | awk -F'[a-z]:' '{ print $2 }'
Linux uptime Alternatives
While the uptime
command in Linux is useful for checking system uptime and load averages, there are several alternatives that provide similar or more detailed information. Here are a few:
- top: The
top
command provides a dynamic, real-time view of the system's running processes, including uptime, load average, and CPU/memory usage.
top
At the top of the output, you will see uptime information along with other system statistics.
- htop:
htop
is an interactive process viewer similar totop
, but with an easier-to-read, color-coded interface.
htop
Uptime information is displayed at the top of the screen, along with CPU, memory, and swap usage.
- w: The
w
command displays information about users currently logged into the system, including their login time and system uptime.
Output includes the current time, system uptime, and load averages, along with details about logged-in users.
- proc filesystem: Reading from the
/proc/uptime
file gives the system uptime in seconds.
The first number is the total number of seconds the system has been up, and the second number is the amount of time spent in idle processes.
- systemd-analyze: If your system uses
systemd
, this command provides detailed boot performance statistics, including system uptime.
For uptime, use: The output includes the system's current state and uptime.
systemctl status
- who: The
who
command can be used with the-b
option to display the last boot time, which can help determine the system's uptime.
uptime
vs /proc/uptime
Feature | uptime Command | /proc/uptime File |
---|---|---|
Output Format | Human-readable | Raw seconds |
Information Provided | Uptime, current time, user count, load averages | Total uptime, idle time |
Usage | uptime | cat /proc/uptime |
Readability | Easy to read | Requires interpretation |
Additional Information | Yes, shows load averages and users | No |
Ease of Use | Very easy | Requires understanding of output |
Typical Use Case | General system status overview | Scripted or detailed analysis |