What is the difference between time and /usr/bin/time?

Let's have a look at what time actually is using the type command (see help type):

$ type -a time
time is a shell keyword
time is /usr/bin/time

So apparently, time on our system is both

  • a keyword directly built into your Bash shell
  • an executable file /usr/bin/time

Because shell keywords take precedence over executables, what you actually run when typing only time is the shell keyword. You also see that from the order in which type -a lists them, or from the output of just type time, which only lists the one effective type.

Now, let's check what each of those can do:

  • Executables usually have a manpage (manual page), which we can open and read using the man command, i.e. here man time.

  • To get help about stuff built into Bash, you have to use the help command: help time

You will note that the shell keyword supports less options than the executable, but it has other advantages, as you can e.g. time complex Bash constructs like pipelines with it. See the end of this answer for an example.

If you need to use the executable instead of the shell keyword though, you can either type the full path, i.e. /usr/bin/time, or you can prefix the command with a backslash to stop Bash from evaluating it: \time

By the way, while time is a shell keyword in Bash, it does not exist in sh (Dash), where you would only get the executable.


When you run time you run a built into shell command that doesn't support all features.

When you run /usr/bin/time, you run a real GNU time program.

You can set an alias to run always the "real" one.

Tags:

Time

Bash

16.04