time – Counts the total time spent by a given command

The time command is a Linux utility that measures the amount of time it takes for a given command to execute. It is useful for determining the performance of a command and for identifying any bottlenecks in a system. The time command is included in most Linux distributions and is a built-in shell command.


The time command is used to measure the execution time of a command. To use the time command, simply prefix the command you want to measure with the time command. For example, to measure the execution time of the ls command, you would enter the following command:

time ls

When the command completes, time will display the execution time of the command, along with other performance metrics such as CPU usage, system calls, and page faults. Here is an example output:

real    0m0.005s
user    0m0.000s
sys     0m0.004s

The real time is the actual time it took for the command to execute, while the user and sys times represent the amount of CPU time used by the command in user and system mode, respectively.


Here are some examples of how to use the time command:

# Measure the execution time of the 'ls' command
time ls

# Measure the execution time of a script
time ./myscript.sh

# Measure the execution time of a command with arguments
time grep -r "hello" /path/to/directory


The time command has the following options:

Option Description
-p Displays the output in a more parseable format
-o FILE Redirects the output to a file
-f FORMAT Specifies a custom output format

Troubleshooting Tips

Here are some troubleshooting tips for the time command:

  • If you are not seeing any output from the time command, make sure that you are running it with a valid command. The time command will not produce any output if the command it is measuring does not produce any output.
  • If you are seeing unexpected output from the time command, check the options you are using to make sure they are correct.


  • The time command is not available on all Unix systems, so be sure to check if it is available on your system before using it.
  • The time command measures the total time spent by a command, including any time spent waiting for I/O or other resources.