Determine System Stability Using the uptime Command

The uptime command in a Ubuntu terminal.
Ricardop0927 / Wikimedia Commons / CC BY 4.0

The one thing that Linux is known for is its stability. We're not necessarily talking about desktop Linux with pretty GUI desktop environments but the bog standard terminal interface that we have all come to love.

Windows users can boast about things like "does it run Microsoft Office" and "there is no decent video editing software" but can they boast an uptime of 365 days or more?

Of course, to be able to boast about how long your system has been up you need to know the command which shows how long it has indeed been up.

This guide will show you how to do just that.

Now obviously if you are running on a laptop then your uptime might be considered small unless you have spent hours playing games, watching online video or indeed working.

The system uptime is far more impressive on a desktop computer left running continuously, a server or everybody's favorite single board computer, the Raspberry PI.

How Long Has Your System Been Running?

The simplest way to find out how long your system has been running is to type the following command into a terminal window:

The default output for the uptime command is as follows:

  • The current time.
  • How long the system has been running.
  • How many users are logged in.
  • The load average for the past 1, 5 and 15 minutes.

The load averages show the average number of processes that are in a runnable or uninterruptable state.

Displaying Just the System Uptime

The uptime command on its own is fairly informative but displaying this information to people in a way that says "Hey look how long my system has been running" can be a little too verbose.

You can display just the uptime in a readable manner using the following command:

The output from the uptime -q command is something like this:

If your system has been up a considerably long time then the output may be something like this:

It might be nicer to show when the system was last restarted. To do this run the following command:

The output from the uptime -s command is as follows: 

If you really want to show off (and we know somebody who does) you can use Twitter from the command line to show the world how long your system has been running.

If you add the command from the linked tutorial to a cron job you can tweet every day to twitter to show how long your system has been running.

Alternate Way to Show Your System Uptime

The uptime command isn't the only way to show the system uptime. You can achieve the same thing with just 2 key presses:

The second keypress is obviously the return key.

The output from the command is as follows:

  • user
  • tty
  • from
  • login time
  • idle time
  • JCPU
  • PCPU
  • WHAT

The command shows more than just the current uptime. It shows who is logged in and what they are currently doing.

The JCPU is the time used by all processes attached to the terminal and the PCPU shows the time used by the current process in the WHAT column. 

The command has a few switches that you can use. For instance to turn off headings run the following command:

You can also display a shorter version using the following command:

The above command shows the following output:

  • user
  • terminal
  • from
  • idle
  • what

If you wish to omit the from field run the following command:

So there you have it. You now know how to show how long your system has been running and you can also find out other useful information about your system's usage.