Linux | Uptime command with examples
Last Updated :
15 Jul, 2024
It is used to find out how long the system is active (running). 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.
Linux uptime Syntax
uptime [-options]
Example:
Input
[mistersubha@server-1 ~]$uptime
08:24:37 up 207 days, 11:10, 0 users, load average: 0.00, 0.03, 0.05
Output

From the above code, the output has got four parts: Current time, Uptime, Number of Users, and average load, as mentioned earlier.
Linux uptime Options
Linux uptime as got few options to tailor outputs and to those who are unaware of the options of the newbies working with uptime can use the option “-h” (which means help). This will give the options available to the preceding command.
[mistersubha@server-1 ~]$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).

Just to make sure you get the uptime in human-readable format, you can use option
“p”
[mistersubha@server-1 ~]$uptime -p
up 29 weeks, 4 days, 11 hours, 1 minute

Option
“s”
is used to get the starting time/specified time when the system started has been running.
[mistersubha@server-1 ~]$uptime -s
2017-11-10 20:14:15

Version information can be shown using option
“V”
.
[mistersubha@server-1 ~]$uptime -V
uptime from procps-ng 3.3.10

There are few other ways to find the uptime and output header of command
“w”
is similar to that of output of
“uptime”
command.
Linux uptime Command Examples
The uptime command in Linux provides information about how long the system has been running, along with the number of users and the system load averages. Here are some examples of using the uptime command:
- Basic Usage: This shows the current time, how long the system has been up, the number of users currently logged in, and the load average over the last 1, 5, and 15 minutes.
uptime

- Using with
-p Option: The -p (pretty) option shows the uptime in a more human-readable format.
uptime -p

- Using with
-s Option: The -s (since) option displays the date and time when the system was last booted.
uptime -s

- Checking System Load Average: This command extracts and displays only the load averages for the last 1, 5, and 15 minutes using
awk.
uptime | awk -F'[a-z]:' '{ print $2 }'

Linux uptime Alternatives
While the uptime command in Linux is useful for checking system uptime and load averages, there are several alternatives that provide similar or more detailed information. Here are a few:
- top: The
top command provides a dynamic, real-time view of the system’s running processes, including uptime, load average, and CPU/memory usage.
top

At the top of the output, you will see uptime information along with other system statistics.
- htop:
htop is an interactive process viewer similar to top, but with an easier-to-read, color-coded interface.
htop

Uptime information is displayed at the top of the screen, along with CPU, memory, and swap usage.
- w: The
w command displays information about users currently logged into the system, including their login time and system uptime.

Output includes the current time, system uptime, and load averages, along with details about logged-in users.
- proc filesystem: Reading from the
/proc/uptime file gives the system uptime in seconds.

The first number is the total number of seconds the system has been up, and the second number is the amount of time spent in idle processes.
- systemd-analyze: If your system uses
systemd, this command provides detailed boot performance statistics, including system uptime.

For uptime, use: The output includes the system’s current state and uptime.
systemctl status

- who: The
who command can be used with the -b option to display the last boot time, which can help determine the system’s uptime.

uptime vs /proc/uptime
| Feature |
uptime Command |
/proc/uptime File |
| Output Format |
Human-readable |
Raw seconds |
| Information Provided |
Uptime, current time, user count, load averages |
Total uptime, idle time |
| Usage |
uptime |
cat /proc/uptime |
| Readability |
Easy to read |
Requires interpretation |
| Additional Information |
Yes, shows load averages and users |
No |
| Ease of Use |
Very easy |
Requires understanding of output |
| Typical Use Case |
General system status overview |
Scripted or detailed analysis |
Uptime – FAQs
How do I find uptime in Linux?
To find uptime in Linux, use the uptime command, which provides a human-readable summary, or check the /proc/uptime file for uptime in seconds with cat /proc/uptime.
How do I see last uptime in Linux?
To see the last uptime in Linux, you can use the last command with the -x option to display system reboots, which will include the uptime for each session:
last -x | grep reboot
What is the uptime command?
The uptime command in Linux displays how long the system has been running, along with the current time, number of logged-in users, and system load averages for the past 1, 5, and 15 minutes.
What is the function of uptime?
The uptime command in Linux displays how long the system has been running, the number of users currently logged in, and the system’s load averages for the past 1, 5, and 15 minutes.
How do I check my uptime?
To check your system’s uptime, you can use the uptime command for a human-readable output or read from /proc/uptime for raw uptime data. Use the following commands:
uptime
cat /proc/uptime
Similar Reads
tracepath command in Linux with Examples
The 'tracepath' command in Linux is a network diagnostic tool used to trace the path packets take to reach a destination, discovering the Maximum Transmission Unit (MTU) along the way. It operates similarly to the traceroute command but does not require superuser privileges and offers a simpler set
2 min read
Traceroute Command in Linux with Examples
In networking, understanding the path that data packets take from one point to another is crucial for diagnosing and troubleshooting connectivity issues. One of the most valuable tools for this purpose is the traceroute command in Linux. Traceroute is a command-line tool used in Linux or other opera
8 min read
Tree command in Linux with examples
In UNIX/LINUX systems, as well as MS-DOS and Microsoft Windows, the tree is a recursive directory listing program that produces a depth-indented listing of files. With no arguments, the tree lists the files in the current directory. When directory arguments are given, the tree lists all the files or
6 min read
tty Command in Linux with Examples
In the Linux operating system, everything is represented within a file system, including hardware devices and terminal interfaces. Among these, the terminal is also treated as a file, allowing users to interact with the system by sending inputs and receiving outputs. One essential command related to
3 min read
type command in Linux with Examples
The type command in Linux is a useful utility for identifying how the shell will interpret a given command. It provides information on whether a command is a shell built-in, external binary, function, or alias, helping users understand the source of the command and its behavior. The command is parti
3 min read
uname command in Linux with Examples
Linux, renowned for its open-source flexibility and powerful performance, offers a range of commands that reveal the inner workings of your system. Among these, the 'uname' command stands out as a versatile tool that provides key details about your Linux machine. Here, we will learn the basics of th
4 min read
unexpand command in Linux with Examples
To convert the leading spaces and tabs into tabs, there exists a command line utility called unexpand command. The unexpand command by default converts each space into tabs writing the produced output to the standard output. Syntax $unexpand [OPTION]... [FILE]...where, OPTION: Represents the various
3 min read
uniq Command in Linux with Examples
The uniq command in Linux is a command-line utility that reports or filters out the repeated lines in a file. In simple words, uniq is the tool that helps to detect the adjacent duplicate lines and also deletes the duplicate lines. uniq filters out the adjacent matching lines from the input file(tha
7 min read
until command in Linux with Examples
until command in Linux is used to execute a set of commands as long as the final command in the 'until' Commands has an exit status that is not zero. It is mostly used where the user needs to execute a set of commands until a condition is true. Syntaxuntil COMMANDS; do COMMANDS; donewhere, CONDITION
2 min read
Linux | Uptime command with examples
It is used to find out how long the system is active (running). 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. Linux uptime S
5 min read
How to add User in Linux | useradd Command
useradd is a command in Linux that is used to add user accounts to your system. It is just a symbolic link to adduser command in Linux and the difference between both of them is that useradd is a native binary compiled with the system whereas adduser is a Perl script that uses useradd binary in the
5 min read
usermod command in Linux with Examples
usermod command or modify user is a command in Linux that is used to change the properties of a user in Linux through the command line. After creating a user we have to sometimes change their attributes like password or login directory etc. so in order to do that we use the Usermod command. The info
4 min read
username Command in Linux With Examples
Linux as an operating system holds the capabilities of handling multiple users. So it is important to keep a check on the users and their related information in order to maintain the integrity and security of the system. Whenever a user is added its information is stored in the "/etc/passwd" file. I
3 min read
users command in Linux with Examples
users command in Linux system is used to show the user names of users currently logged in to the current host. It will display who is currently logged in according to FILE. If the FILE is not specified, use "/var/run/utmp". "/var/log/wtmp" as FILE is common. Syntaxusers [OPTION]... [FILE]where, OPT
2 min read
How to Delete User in Linux | userdel Command
Managing user accounts is an essential aspect of Linux system administration. Understanding how to delete a user in Linux is crucial, whether you need to remove an unused account, revoke access for a departing employee, or clean up your system for security reasons. Here, we will explore the 'userdel
6 min read
vi Editor in Linux
The default editor that comes with the Linux/UNIX operating system is called vi (visual editor). Using vi editor, we can edit an existing file or create a new file from scratch. we can also use this editor to just read a text file. The advanced version of the vi editor is the vim editor. Table of C
9 min read
vmstat command in Linux with Examples
vmstat command in Linux/Unix is a performance monitoring command of the system as it gives the information about processes, memory, paging, block IO, disk, and CPU scheduling. All these functionalities makes the command vmstat also known as virtual memory statistic reporter. The very first report pr
3 min read
vnstat command in Linux with Examples
vnstat is a command-line tool in Linux that is generally used by system administrators in order to monitor network parameters such as bandwidth consumption or maybe some traffic flowing in or out. It monitors the traffic on the system's network interfaces. Installing vnstat on LinuxIn case of RedHa
4 min read
w command in Linux with Examples
The 'w' command in Linux gives us important information about who is currently using the computer, how much the computer is being used, and what programs are running. It's a handy tool for people who take care of computer systems, as it helps them keep an eye on what users are doing, how much of the
3 min read
wall command in Linux with Examples
wall command in Linux system is used to write a message to all users. This command displays a message, or the contents of a file, or otherwise its standard input, on the terminals of all currently logged in users. The lines which will be longer than 79 characters, wrapped by this command. Short line
3 min read
watch command in Linux with Examples
The 'watch' command in Linux is a powerful utility that allows you to execute a command periodically, displaying its output in fullscreen mode. It is particularly useful for monitoring the output of commands that change over time, such as system resource usage or server status. By default, 'watch' r
4 min read
wc command in Linux with examples
wc stands for word count. As the name implies, it is mainly used for counting purpose. It is used to find out number of lines, word count, byte and characters count in the files specified in the file arguments.By default it displays four-columnar output.First column shows number of lines present in
6 min read
Wget Command in Linux/Unix
Wget is the non-interactive network downloader which is used to download files from the server even when the user has not logged on to the system and it can work in the background without hindering the current process. GNU wget is a free utility for non-interactive download of files from the Web. It
6 min read
whatis Command in Linux with Examples
whatis command in Linux is used to get a one-line manual page description. In Linux, each manual page has some sort of description within it. So, this command search for the manual pages names and show the manual page description of the specified filename or argument. Syntax of the `whatis` command
5 min read
How to Display Path of an Executable File in Linux | Which Command
In Linux finding the exact path of an excutable file can be crucial for the system adminstration, scripting and as well for troubleshooting. The `which` command helps with providing a simple and effective way to locate the executable files within the directories that are listed in your system. In th
6 min read