Uptime Command in Linux

superior_hosting_service

What is Uptime Command in Linux With Example

uptime-command-linux-1024×577.png

In this tutorial, we will cover the uptime command.

As its name suggests, the uptime command shows how long the system has been running. It also displays the current time, the number of logged-in users, and the system load averages for the past 1, 5, and 15 minutes.

How to Use the Uptime Command

The syntax for the uptime command is as follows:

$ uptime [OPTIONS]

To display the system uptime, invoke the command without any options:

$ uptime

The output will look something like below:

22:20:33 up 620 days, 22:37,  1 user,  load average: 0.03, 0.10, 0.10
  • 22:20:33 – The current system time.
  • up 620 days, 22:37 – The length of time the system has been up.
  • 1 user – The number of logged-in users.
  • load average: 0.03, 0.10, 0.10 – System load averages for the past 1, 5, and 15 minutes.

The information displayed by uptime is the same as the information contained in the header of the w command.


System load average measurement of the number of jobs that are currently running or waiting for disk I/O. It basically tells you how busy your system has been over the given interval.

If the load averages are 0.0, then the system is mostly idle. If the load average for the past 1 minute is higher than the 5 or 15-minute averages, then the load is increasing. Otherwise, the load is decreasing.

The load average usually increases due to higher CPU consumption or disk workload.

To better understand the Linux load averages check the Brendan Gregg’s article: Linux Load Averages: Solving the Mystery .

uptime options

The uptime command accepts only a few options that are rarely used.

The -p--pretty option tells uptime to display the output in a pretty format:

$ uptime -p

The command will display only how long the system has been running:

OUTPUT
up 1 year, 36 weeks, 4 days, 23 hours, 15 minutes

The -s--since option shows the date and time since the system is up:

$ uptime -s
OUTPUT
2020-09-01 23:43:32

Other two options are:

  • -h--help – Display a help message and exit.
  • -V--version – Shows the version information and exit.

Conclusion

The uptime command gives you information about the current time, online users, how long your system has been up and running, and the system load average.

If you have any questions or feedback, feel free to leave a comment.