« Back to System administration: Frequently Asked Questions

How to see when the system was started (uptime)

To know when a system was started, we want to query its uptime, or the time since booting up. With the uptime command, we can easily retrieve this information. Let’s have a look!

System uptime

To request the uptime, simply run the command without any parameters.

# uptime
 08:26:05 up 13 days,  8:29,  4 users,  load average: 0.06, 0.02, 0.00

This output gives a good impression, but is not very precies. To zoom in to a specific date and time, use the --since option.

# uptime --since
2024-05-08 23:56:06

This output is easier to read and tells us the exact time when the system was started.

Query init process details

We can also query the start time of the first process, which is normally the init system.

ps -o lstart= -p 1
Wed May  8 23:56:05 2024

As expected, this shows a similar time as our uptime output above. By using -o we can select the columns that we are interested in. The ‘=’ in the column name means the related header will be hidden.

Using systemd to determine uptime

If the system is using systemd, we can also use systemctl to query one of the first targets. We can see the start time as an date, but also in seconds.

# systemctl show --property ActiveEnterTimestamp init.scope
ActiveEnterTimestamp=Wed 2024-05-08 23:56:09 UTC

Most likely this will have a slightly different time as the other commands, as this is a recorded time of a state change within the related systemd unit (scope).

Also the journal will reveal the boot time.

# journalctl --list-boots | tail -1
  0 7ec0e89c1de74b71bcc9e004a7f30d45 Wed 2024-05-08 23:56:09 UTC—Wed 2024-05-22 09:45:01 UTC

An alternative is to select the current boot (id 0) and pull in the first line. journalctl --boot=0 | head -1

Got other options to query the uptime of a system?

Relevant commands in this article

Like to learn more about the commands that were used in this article? Have a look, for some there is also a cheat sheet available.

  • ps
  • uptime

Other questions related to System administration


Is the described answer not working or incorrect, got another tip or question? Share your thoughts!