Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

uptime

Display how long the system has been running.

Description

Prints the current time, how long the system has been running, and the system load averages for the past 1, 5, and 15 minutes.

Inputs

  • /proc/uptime – system uptime in seconds and idle time
  • /proc/loadavg – 1, 5, and 15 minute load averages
  • /var/run/utmp – counted for the N users field; parsed via the shared utmp module

Arguments

FlagDescription
-p, --prettyShow uptime in human-readable format
-s, --sinceShow the date/time when the system booted

Behavior

Default mode

Prints a single line with the current time, uptime duration, the number of USER_PROCESS entries in utmp, and load averages:

 14:30:00 up 3 days,  2:15,  3 users,  load average: 0.50, 0.30, 0.20

The uptime portion adapts its format based on duration:

  • 1+ days: N days, H:MM
  • Less than a day: H:MM
  • Less than an hour: M min

Pretty mode (-p)

Prints only the uptime in a human-readable format:

up 3 days, 2 hours, 15 minutes

Components with a value of zero are omitted. Singular/plural forms are used correctly (“1 day” vs “2 days”). If uptime is less than one minute, prints “up 0 minutes”.

Since mode (-s)

Prints the boot timestamp in YYYY-MM-DD HH:MM:SS format using the local timezone:

2024-01-15 08:30:00

Exit codes

CodeMeaning
0Success
1Failure (cannot read proc files)