Time command is useful when you want to determine the command execution time. Generally, it’s useful to test the performance of the commands and scripts. In this guide, we will cover how to use the
time command in Linux.
When you are writing multiple script which doing same job and want to choose better one by performance, you can use the
time command to test the execution
time of each script.
Time Command Versions
The most widely used Linux shells Bash and Zsh have their built-in versions of the
time command which is better than the Gnu
Use the type command to determine whether the
time is a binary or a built-in keyword.
time is a shell keyword
time is a reserved word
# GNU time (sh)
time is /usr/bin/time
time command, you need to specify the full path
/usr/bin/time to the
time binary. Use the
env command or use a leading backslash
\time which prevents both and built-ins from being used.
You can format the output and show other useful information like memory I/O and IPC calls using the Gnu
Using Linux Time Command
time wget https://wordpress.org/latest.tar.gz
The output is depends on the version of the
time command which your system have:
0.042s user 0.092s system 1% cpu 3.565s total
# GNU time (sh)
0.042user 0.092system 0:03.57elapsed 1%CPU (0avgtext+0avgdata 6060maxresident)k
0inputs+201456outputs (0major+315minor)pagefaults 0swaps
- The real or total or elapsed is showing the
timewhich taken from start to
- user – amount of CPU
timespent in user mode.
- system or sys – It shows the amount of CPU
timespent in kernel mode.
You successfully learned how to use the
time command. You can learn more about the Gnu time command by visiting the time man page.
If you have any question or feedback, please leave a comment below.