VPS

How to Use the Linux Time Command

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.

First, we have to connect to our VPS using SSH. If you’re having trouble, check out our PuTTY tutorial!

Then, we can execute the following command to show the command information in the terminal.

man time

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:

touch output.txt

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.

Conclusion

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!

About the author

Edward S.

Edward is Hostinger's copywriter. He's an expert communicator with years of experience in IT as a writer, marketer, and Linux enthusiast. IT is a core pillar of his life, personal and professional. Edward's goal is to encourage millions to achieve an impactful online presence. He also really loves dogs, guitars, and everything related to space.

Add Comment

Click here to post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get Exclusive Content

Join thousands of webmasters who get our free newsletter with tips on how to drive more traffic and revenue to their websites!

Please wait...

Thank you for sign up!

More in VPS
What is the Linux Watch Command + Examples
Close