How to use uptime command on Linux

The purpose of this guide is to go over the uptime command on Linux. It’s a rather simple command that will only take you a minute or two to master, but it will come in handy more than you might expect.

Follow along with us below as we show various examples of uptime and the options you can use with the command. We’ll also see why the command can be useful.

In this tutorial you will learn:

  • What is the uptime command used for?
  • How to use uptime command with examples
uptime command on Linux

uptime command on Linux

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software uptime
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

What is the uptime command used for?



The uptime command does exactly as its name implies, it shows you how long it’s been since the system was rebooted (how much “uptime” it has accrued). It also outputs some other handy data – the current time, how many users are logged in, and the CPU load average for the last 1, 5, and 15 minutes.

$ uptime
 22:04:18 up 22 min,  1 user,  load average: 0.09, 0.08, 0.28

Knowing your system’s uptime can be useful for a lot of reasons. For example, if you receive report from users that your server is unreachable, you can run the uptime command to quickly see if there’s been a recent (unexpected) reboot.

Using uptime for troubleshooting, like in the scenario above, is probably the most practical use for the command. But it also offers insight into the stability of your system. Linux is well known for its extreme stability, and it’s not at all out of the ordinary to see machines running Linux with an uptime of over one year, or other crazy amounts of time.

A high uptime is a coveted achievement for Linux admins, and acts as a testament to the stability of their configuration. Not only does the uptime command give us some quick troubleshooting information, but it’s also good for bragging rights.

Uptime command with examples

Executing the uptime command without any options will output the current time, uptime, number of users logged in, and CPU load averages.

$ uptime
 22:04:18 up 22 min,  1 user,  load average: 0.09, 0.08, 0.28

Using the -p option will just show your system’s uptime.

$ uptime -p
up 22 minutes


To see the date and time of when the system last booted, use the -s option.

$ uptime -s
2021-01-29 21:41:31

In case you forget any of these options, you can always check out the help page by specifying the -h option.

$ 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).

Closing Thoughts

In this guide, we saw how to use the uptime command on Linux, along with its different options. We also learned about the motivation behind the command, and why it’s useful for troubleshooting or simply measuring system stability.



Comments and Discussions
Linux Forum