Linux Time Command

The time command is used to determine how long a given command takes to run. It is useful for testing the performance of your scripts and commands.
For example, if you have two different scripts doing the same job and you want to know which one performs better, you can use the Linux time command to determine the duration of execution of each script.
Time Command Versions
Both Bash and Zsh, the most widely used Linux shells, have their own built-in versions of the time command which take precedence over the GNU time command.
You can use the type command
to determine whether time is a binary or a built-in keyword.
type time# Bash
time is a shell keyword
# Zsh
time is a reserved word
# GNU time (sh)
time is /usr/bin/timeTo use the GNU time command, you need to specify the full path to the time binary, usually /usr/bin/time, use the env command, or use a leading backslash \time which prevents built-ins from being used.
GNU time allows you to format the output and provides other useful information like memory I/O and IPC calls. You can also use it before pipelines, for example \time cmd | cmd2, to measure the whole pipeline.
Using Linux Time Command
In the following example, we are going to measure the time taken to download the Linux kernel using the wget tool :
time wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.11.5.tar.xzThe output depends on the version of the time command you’re using:
# Bash
real 0m33.961s
user 0m0.340s
sys 0m0.940s
# Zsh
0.34s user 0.94s system 4% cpu 33.961 total
# GNU time (sh)
0.34user 0.94system 0:33.96elapsed 4%CPU (0avgtext+0avgdata 6060maxresident)k
0inputs+201456outputs (0major+315minor)pagefaults 0swaps- real or total or elapsed (wall clock time) is the time from start to finish of the call. It is the time from the moment you hit the
Enterkey until the moment thewgetcommand is completed, and is usually the most useful number. - user - amount of CPU time spent in user mode.
- system or sys - amount of CPU time spent in kernel mode.
Conclusion
By now, you should have a good understanding of how to use the time command. If you want to learn more about GNU time, visit the time man page
.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors

Dejan Panovski
Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.
View author page