How to get the execution time of any command in Linux

Overview

The time command is used to determine the amount of time it takes for a command to run. time prints a summary of real time, user time, and sys or system time spent while executing the given command.

  • real time refers to the wall clock time taken from the start to the finish of the command.
  • user time refers to the amount of CPU time spent in executing the command in user mode.
  • sys/system time refers to the amount of CPU time spent in executing the command in kernel mode.

Syntax

time COMMAND_TO_EXECUTE

For example, time sleep 5 or time echo "hello".

Example

time sleep 2

Free Resources