The Linux terminal is one of the most powerful tools in all computing. In it, we can execute various important administration operations. With it, we can measure how long it takes for a command to run. That’s why, in this post, we will teach how to use the Linux time command.
What is The Linux Time Command
The Linux Time command is a command used to determine the execution time of a specific operation. Thanks to this command, we can know the exact duration of a process in any Linux operating system.
In addition, we can find out about their execution in the processor. Normally, the Linux time command is used to measure the performance of commands associated with services managed by the network.
Then, we can execute the following command to show the command information in the terminal.
The basic syntax of the Linux time command is as follows:
time [-options] command
It looks the same on any Unix based system. Let’s break the syntax down:
- time – indicated the use of the command
- [-options] – allow us to add modifiers to the command
- command – is where we type in what we want to inspect
To verify the time it takes for a command to run, for example, to verify the contents of the root folder, we would do it by typing in this string into the command line:
time ls -l /
As we can see, at the end of the execution of the command, there are three results:
- Real – refers to the time that has elapsed between execution and completion of the command
- User – is the time spent by the user on the processor=
- Sys – the time used by the system (kernel) to run the command
There are several options that modify the behavior of the time command. A useful option is to export the results to a text file. We can do this with the -o option. However, first, we’ll need to create the file. We can do this with the touch command:
Next, run the time command with the -o option.
time ls -l / -o output.txt
Using this method, we can carefully examine how long it takes for a command to run.
The Time command is a simple-to-use command that lets you know how long it takes for a process to run. This utility gives us valuable insights into the performance of our servers, networks, or machines. This is a must-have tool in the arsenal of any networking expert or system administrator.
We recommend you to learn more about this command with the help of the manual available in the terminal. Good luck!