The uptime command is one of the many resourceful Linux utilities for sysadmins that is capable of telling the system boot related information like the current time, the uptime (in days and hours), the number of users currently logged on to the system, and the load average.
The introduction went too far, but the utility is pretty simple for beginners to understand, so let’s start with practical examples.
|Description||Check how long the system has been running.|
|Root or Sudo Privileges||No|
|Host System and Architecture||Ubuntu 22.10 (x64)|
|OS Compatibility||Ubuntu, Manjaro, Fedora, etc.|
|Discussed Tools in this Article|
Usage of the Uptime Command
The uptime command takes only one argument as an option (optional).
$ uptime [OPTION]
Now, if you run this command without any options, you will get something like this as a result.
Fun Fact: The first line of the w command is the same as the uptime output.
The above output includes the following fields:
- System time: The current time of the system.
- Up time: How long the system has been running (2 hours and 36 minutes).
- Number of users: The count of all the logged-in users.
- Average system load: The average CPU load for the past 1, 5, and 15 minutes.
The following is an example of this command when executed without any options:
The uptime pulls the boot related information from the “/proc” files, and user-related information is fetched from the “/var/run/utmp” file.
Check Historical and Statistical Uptime of Linux Using the Tuptime
Uptime Command Syntax
The uptime command supports a few options that directly reflect the output when they are applied, so let’s see each of these options, starting with
Show Output in Pretty Format
If you think the uptime output is too cluttered with unnecessary stuff, then you can use the “
-p” flag to get clean output.
$ uptime -p
The above command will only show you the uptime information (how long your system has been running) in words.
As you can see from the above picture, the target machine was booted 13 minutes ago.
Show the Date and Time When the System Booted Up
-s” flag will only return the date and time when the system booted up.
$ uptime -s
From the above picture, it appears that the target machine has booted at “2023-01-11” at “10:11:07“, which is quite mysterious since I did not restart or do anything at that time.
Let me check the historical record of uptime for the target machine using the uprecords command; until then, you can check our other articles.
Also, don’t forget to tell me when your system last booted or restarted in the comments section.
Till then, peace!
Join The Conversation
Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.