The Linux terminal is one of the most versatile tools in the operating system. Many professionals use it every day to manage servers or work with networks and other things. In other words, it is a tool for all professions. That is why, in this opportunity, I will teach you a basic command, a very simple one to learn that can be very profitable. In this post, I will introduce you to the Linux uptime command.
Basic usage of the Linux uptime command
The uptime command is one of the most basic of all Linux shells. It is a command that allows you to know how long the system has been running.
Thanks to this command we will be able to program system restarts based on the time the system has been running. Personally, I use it for that. Also, to know when a workstation corresponds to a reboot.
Also, uptime gives a one line display of the following information. The current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.
So, if you use the uptime command like this without any parameters, you will get the following.
:~$ uptime 16:55:12 up 1:41, 1 user, load average: 1,62, 1,19, 1,04
Now, I will explain briefly what the output obtained means:
- 16:55:12 -> This is the local time of the computer where we are running the command.
- up 1:41 -> This is the amount of time the system has been running. In my case, it is about 2 hours.
- 1 user is active.
- Load Average -> Displays last minute system load, last 5 minutes and last 15 minutes. This is taken based on the average of processes waiting to do disk I/O tasks. The lower the value, the more inactive the system has been.
On the other hand, the Linux uptime command has few options. If you want to display the information in a more readable format, use the -p option.
:~$ uptime -p up 2 hours, 12 minutes
Or use the -s option to only show from when the system is active.
:~$ uptime -s 2019-05-17 15:13:47
If you want more information about the command, you can use the -h option.
:~$ uptime -h
So, that is it.
The uptime command is one of those commands quite easy to use but that can be useful in many cases. This way you will improve your use of the terminal and you can use that information in a bash script.