Linux Server Uptime Command To Find Out How Long The System Has Been Running

I would like to find out how long the system has been running under a UNIX or Linux operating system. How do I find out system uptime? How to tell how long the Linux system has been running on?

Both Linux and Unix-like systems come with various command to find out server uptime command. Under Linux file /proc/uptime has uptime information and file/var/run/utmp has information about who is currently logged on. However, info from /proc/uptime or utmp file is not directly readable by humans; therefore, you need to use the following commands. This page shows command that tell how long the Linux and Unix-based system has been running.

ADVERTISEMENTS

Linux Server Uptime Command

Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following command:
$ uptime
Sample outputs:

 21:54:11 up 13 days,  4:29,  1 user,  load average: 0.21, 0.21, 0.12

The uptime command gives a one line display of the following information.

  • The current time (21:54:11)
  • How long the system has been running (up 13 days)
  • How many users are currently logged on (1 user)
  • The system load averages for the past 1, 5, and 15 minutes (0.21, 0.21, 0.12)

See uptime in pretty format pass the -p option to the uptime command

$ uptime -p
Sample outputs:

up 3 days, 2 hours, 11 minutes

This is the same information contained in the header line displayed by the w command and top command:
$ w
Sample outputs:

 21:56:06 up 13 days,  4:31,  1 user,  load average: 0.03, 0.14, 0.09
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    123.xxx.yy.zzz    21:54    0.00s  0.02s  0.00s vi

Getting help about uptime command

To check system uptime in Linux and Unix we use the uptime command. However, if you need more information on command option type the following man command:
$ man uptime
OR
$ uptime --help
Sample outputs:

 -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

Use top command to display Linux system uptime

Type the following command:
$ top
Sample outputs:

Fig.01: UNIX and Linux server uptime command to display system uptime

Fig.01: UNIX uptime top command output

Please note that the w command displays who is logged on and what they are doing while top command provides a dynamic real-time view of a running Linux/UNIX/BSD operating systems including processes.

Conclusion

In this quick tutorial, you learned how to use uptime, w, and top commands to see system uptime and other information from the command line.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
20 comments… add one
  • Onur Buyukceran Jul 22, 2007 @ 1:39

    my favorite :) updates every second….

    top -d 1

  • Benjamin Alawani Aug 26, 2009 @ 9:30

    Nice looking site; useful and clear information. Good job!

  • Andy Konecny Mar 10, 2010 @ 21:49

    The only problem with the uptime command is that it isn’t always obvious what units of measure to the time it has been up. Just a bit confusing for those new to it, especially those from the Windoze world trying to come over to Linux. Just fleshing out the units (up 5 hours:54 minutes (days:hours:minutes)) on this would certainly help in bringing more over, especially if we can get into the man&info pages.

    • Mohamed Nov 28, 2010 @ 4:57

      $ uptime
      07:55:56 up 3 days, 17:37, 6 users, load average: 0.04, 0.06, 0.01
      $

      by default it will give how many days the OS is up, and how many hours:mins.
      if it less than 1 day, it will give only hours:mins.

  • Anwar Dec 3, 2010 @ 8:33

    Wonderful.

    • Rico Jun 29, 2015 @ 7:57

      what is the command for checking how many bites are already downloaded in your server

  • Ravi May 10, 2011 @ 13:24

    Hi,

    How do I get only time information excluding other load information

    Thanks,
    Ravi.

  • joe Apr 19, 2012 @ 18:18

    How do I get only time information excluding other load information

    # 1. run Command
    # 2. strip unneeded leading data
    # 3. check if the uptime is greater than 24 hours
    # 4. make the output human readable
    # 5. trim any leading space

    uptime | \
    sed s/^.*up// | \
    awk -F, '{ if ( $3 ~ /user/ ) { print $1 $2 } else { print $1 }}' | \
    sed -e 's/:/\ hours\ /' -e 's/ min//' -e 's/$/\ minutes/' | \
    sed 's/^ *//'
  • Igor Sep 3, 2012 @ 9:37

    For people who want to get uptime within a C program I would suggest having a look at sysinfo() too…

  • mk Mar 15, 2013 @ 20:56

    nice and so useful
    thank you

  • Brookly Apr 3, 2013 @ 15:16

    How can i know uptime of a server machine without logging in it ?? Is there any way?

  • kunal Jul 15, 2013 @ 13:47

    Hello Buddies , plz specify whats the value ‘4:29’ in the above output.

  • Pradeep Jan 27, 2014 @ 13:02

    @Kunal It’s 4 hours and 29mins. So from the output the server uptime is 13 days, 4 hours and 31 mins.

  • Viet Aug 13, 2014 @ 0:02

    thanks for this!

  • Jim Nov 17, 2014 @ 15:54

    Did you see the output within one hour of startup? Is it, e.g. 0:15, :15 or 15 for the 15 minutes after startup?

  • davux Feb 2, 2015 @ 19:55

    On most systems you can do cat /proc/uptime if you’re only interested in the uptime. The first number is how many seconds the system has been up for, and the second number is how many seconds it’s spent idle.

  • Joe Aug 4, 2015 @ 8:47

    Tuptime is a uptime with steroids, nice tool for getting uptime, downtime and other interesting stuff:
    https://github.com/rfrail3/tuptime

  • Nagesh Jan 5, 2016 @ 17:08

    How can i see the only up time without any other information is there Any command to know only the Uptime i mean to say the if i issue a command it should print 21:54:11 up 13 days, 4:29

  • sai swain May 14, 2016 @ 18:37

    A server is up. wht does it mean ?

  • vivek tudi Feb 28, 2017 @ 23:17

    useful

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.