, , ,

Linux PC with a terminal window open
Fatmawati Achmad Zaenuri/Shutterstock.com

Want to know how long a process runs and a whole lot more? The Linux time command returns time statistics, giving you cool insights into the resources used by your programs.

time Has Many Relatives

There are many Linux distributions and different Unix-like operating systems. Each of these has a default command shell. The most common default shell in modern Linux distributions is the bash shell. But there are many others, such as the Z shell (zsh) and the Korn shell (ksh).

All of these shells incorporate their own time command, either as a built-in command or as a reserved word. When you type time in a terminal window the shell will execute its internal command instead of using the GNU time binary which is provided as part of your Linux distribution.

We want to use the GNU version of time because it has more options and is more flexible.

Which time Will Run?

You can check which version will run by using the type command. type will let you know whether the shell will handle your instruction itself, with its internal routines, or pass it on to the GNU binary.

in a terminal window type the word type, a space, and then the word time and hit Enter.

type time

type time in a bash terminal window

We can see that in the bash shell time is a reserved word. This means Bash will use its internaltime routines by default.

type time

type time in a zsh terminal window

Read the remaining 46 paragraphs