In Linux, the “uptime” command determines how long the system has been in an active state. It shows the system date and time, system uptime, logged-in users, and load averages. It is part of the GNU core utility packages and is available on almost all Linux distributions.
This post aims to illustrate the working and functionality of the “uptime” command in Linux. The guideline of this post is defined below:
- What is the uptime Command in Linux?
- How to Use uptime Command in Linux?
What is the uptime Command in Linux?
The “uptime” command is typically used to check the stability and availability of a Linux system. Before digging into detailed usage. Check out the syntax followed by it:
The basic structure of the “uptime” command is typed below:
$ uptime [OPTION]
In the syntax of the “uptime” command, “uptime” is the main keyword while the square brackets show its supported “options”.
The commonly used options of the “uptime” command are explained deeply in the below table:
|-h||Provides the “uptime” command help page that holds its basic pieces of information.|
|-s||Shows the system’s last booted date and time.|
|-p||Represents the system uptime in an easy and human-readable format.|
|-V||Displays the “uptime” utility version.|
In addition, use the “help” command to get a detailed view of the “uptime” command:
$ uptime --help
How to Use uptime Command in Linux?
Generally, the “uptime” command shows the time when the system has been started. However, it provides some additional information as well. Here, in this section, some practical examples are described to see the usage of the “uptime” command.
Example 1: Display the System
Simply running the “uptime” command without any argument or option displays the system running uptime and some other important information in one line. Type the below command on the terminal and see the output:
The “uptime” command output contains the following components:
- Current System’s Time: In our case, it is “19:11:43”, which is “7:11 PM”.
- System Uptime: It displays the time when the system is active. The system has been up for about “13” minutes in the above output.
- No of Logged-in Users: The currently logged-in user in this example is only “1”.
- Load Averages: The load averages indicate how many processes are currently running or waiting to use the CPU after the last “one”, “five”, and “fifteen” minutes.
Example 2: Check the Running Time of the System
The “-p” option of the “uptime” command only shows the system running time in a pretty or human-friendly format:
$ uptime -p
The output denotes that the current system is running up from “1” hour and “17” minutes.
Example 3: Identify the System Startup Time
The “uptime” command with the “-s” option displays the current date and time when the system last booted:
$ uptime -s
In the above output, the system has last booted on “01-12-2022”.
The “uptime” command is present in most Linux distributions. It provides the system running uptime and other important information. The generalized syntax of the “uptime” command is “$ uptime [OPTION]”. Furthermore, it provides important options that show output according to the user’s needs. This post has described the objective, usage, and working of the “uptime” utility, along with practical examples.