How to measure the execution time of a command in Linux

When working on the command line in Linux, you may want to know how much time a particular command has taken (from start to finish).

If you are new to Linux and looking for a way to do this, you will be pleased to learn that there is a command-line tool that does exactly what you want. The tool in question is called "time". In this guide, I will show you how to use the time command. We will measure how long a Linux command takes to execute.

Please note that all instructions and examples mentioned here have been tested on Ubuntu 20.04.

Measure command execution time with Linux time command

According to the tool's man page, time runs programs and summarizes system resource usage. By default, the command produces time-related information.

Using the tool is very easy - all you have to do is to pass your command as input to the 'time' command.

time [command]

For example:

time wget

Measure app exec time

I've highlighted the output of the time command at the bottom.

  • 'real' time is the elapsed wall clock time taken by the wget command.
  • 'user' and 'sys' times are the number of CPU-seconds that 'wget' used in user and kernel mode, respectively.

To learn more about the time command, head to its man page.

Leave a Comment