Administration toolsCommands

How to use linux uptime command

If you are a Linux newbie, and have interest in system administration, or you want to become a power user, then you need to have a solid knowledge of the command line. There are several commands that you should know about, and one of them is uptime. 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.

In this article, we will discuss the basics of this command using some easy to understand examples.

uptime uses a simple syntax:

# uptime [option]

Options:

-h–helpDisplay a brief help message, and exit.
-V–versionDisplay version information, and exit.
-p–prettyShow uptime in pretty format.
-s–sinceSystem up since.

How to use the uptime command

Uptime’s basic usage is very easy – just write the command’s name and press enter.

~$ uptime

It will display an output similar to:

rasho@Gandalf:~$ uptime
 07:54:50 up 24 days, 17:53,  1 user,  load average: 1,74, 1,81, 1,99

In order of appearance, the command displays the current time as the 1st entry, up means that the system is running and it is displayed next to the total time for which the system has been running, the user count (number of logged on users), and lastly, the system load averages.


What are system load averages? It is the average number of processes that are in a runnable or uninterruptable state. A process is in a runnable state when it is using the CPU or waiting to use the CPU; while a process is in an uninterruptable state when it is waiting for I/O access like waiting for a disk.

How to make the tool show up time in pretty format

In case you just want to know the time for which the system has been up, and that too in a more human-readable format, use the -p command line option.

~$ uptime -p

Example output:

rasho@Gandalf:~$ uptime -p
up 3 weeks, 3 days, 18 hours, 10 minutes

Check Linux Starting Time

You can also make uptime specifically display the time/date since when the system has been running. This can be done using the -s command line option.

~$ uptime -s

Example output:

rasho@Gandalf:~$ uptime -s
2019-05-31 14:01:44

Uptime Version & Help

As it is with most command line apps, you can display uptime’s version information and quick help page with the following command.

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

Conclusion

You have successfully learned how to use uptime command in Linux. If you have any queries regarding this then please don’t forget to comment below.

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA


This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button