uptime command in Linux is used to display the system’s current uptime, which refers to the time duration for which the system has been running since its last boot. It also provides information about the system’s load average over different time periods.
Syntax:
The basic syntax for the uptime command is
uptime
Example:
Displaying System Uptime and Load
$ uptime
Output:
13:37:45 up 19:10, 2 users, load average: 0.00, 0.06, 0.11
The uptime command provides the following information:
- Current time: 13:37:45
- System uptime: The system has been operational for 19 hours and 10 minutes since the last boot.
- Number of users: There are currently 2 users logged into the system.
- Load average: It displays the load average for the past 1, 5, and 15 minutes respectively. In this case:
- Load average for the past 1 minute: 0.00
- Load average for the past 5 minutes: 0.06
- Load average for the past 15 minutes: 0.11
Advanced Options:
The uptime command provides additional options for enhanced functionality:
- -p, –pretty: Displays the uptime in a more human-readable format, removing the seconds from the days:hours:minutes representation.
- -s, –since: Displays the system’s uptime since a specific date or time. The format for the date and time can be specified using the -s option along with the desired format.
- -V, –version: Displays the version information for the uptime command.
Advanced Options Examples:
Example 1: Display Uptime in a User-friendly Format
uptime -p
The -p option presents the system’s uptime in a more human-readable format, showcasing the duration the system has been up in a user-friendly manner, excluding seconds.
Output:
up 1 week, 2 days, 5 hours
Example 2: Show System Uptime Since a Specific Date/Time
uptime -s
The -s option displays the system’s uptime since a specific date and time. In this case, it indicates the date and time when the system was last booted.
Output:
2023-11-10 08:30:00
Example 3: Display Version Information
uptime -V
Output:
uptime from procps-ng 3.3.12
The -V option provides the version information for the uptime command, showing the version and related details about the command utility (procps-ng in this case).
Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.
- Practice Programming MCQs
- Apply for Programming Internship
- Check Information Technology Books
- Check Linux Books