I tried to use time command with -f option to format the output of time, but I get the following error:

-f: command not found

Then I tried to use other options -a, -o, etc and I get the same error. Not even time --version doesn't work (--version: command not found).

Don't tell me to read the man because I already do it by many times... All these options are specified there. So, where could be the problem?

  • Does sudo apt-get install --reinstall time help?
    – jobin
    Mar 14, 2014 at 17:53
  • 10
    Or maybe the internal shell time with /usr/bin/time
    – Rmano
    Mar 14, 2014 at 17:53

3 Answers 3


Well, even if you don't like it, I will put you to read again with more attention man time. At the end of EXAMPLES section you will find:

  Users of the bash shell need to use an explicit path in order to run
  the external time command and not the shell builtin variant.  On system
  where time is installed in /usr/bin, the first example would become
       /usr/bin/time wc /etc/hosts

So, I'm assuming that you use bash shell which uses an internal version of time, provided as a shell keyword. You can check this using the following command:

type time

and the output will probably be:

time is a shell keyword

If this is the case, then it is clear that to use the real time command you must use its explicit path: /usr/bin/time.

Further, if you don't want to use anymore the shell keyword time, you can create a permanent alias as follow:

alias time='/usr/bin/time'

This will overwrite the shell keyword time because the command:

type time

will give the following output now:

time is aliased to `/usr/bin/time'
  • 7
    for the shell built commands: {info time} and {type time}. For the binary commands: {which time} and {man time} Mar 14, 2014 at 19:09
  • 1
    @Michael info time is about the binary. help time is about the builtin.
    – wjandrea
    Dec 23, 2018 at 4:26
  • yep, sorry I was thinking "help" but out came "info" Jan 7, 2019 at 17:15
  • 1
    I skimmed the man page three times and still missed the bash caveat. I guess the adage is RTFM and not SkimTFM for a reason... May 27, 2021 at 16:22
  • 3
    Rather than write out the full path to the binary, you can escape a command (i.e. \time) to avoid it being interpreted as a shell builtin or alias.
    – Jivan Pal
    Jul 27, 2021 at 20:46

Since, as the other answers explain, time is a shell keyword, the only option available to you is -p:

terdon@oregano ~ $ help time
time: time [-p] pipeline
    Report time consumed by pipeline's execution.

Execute PIPELINE and print a summary of the real time, user CPU time,
and system CPU time spent executing PIPELINE when it terminates.

  -p    print the timing summary in the portable Posix format

So, you need to run the time that's in /usr/bin. Here are a few ways to do so:

  • Use the time executable instead:

    /usr/bin/time -f %Uuser ls >/dev/null
  • Use \ which causes your shell to ignore aliases and keywords and instead search your $PATH for a matching executable:

    \time -f %Uuser ls >/dev/null 
  • Use the command builtin which has a similar effect:

    command time -f %Uuser ls >/dev/null
  • Use a different shell, one that has no such keyword. For example sh (which is actually dash on Ubuntu):

    sh -c "time -f %Uuser ls >/dev/null"
  • Use which, which will search through your $PATH (OK, this one is silly):

    $(which time) -f %Uuser ls >/dev/null
  • Is there a way to do the opposite - replicate built-in time with regular /usr/bin/time? I.e. to translate bash script into dash.
    – Dan M.
    Sep 26, 2019 at 12:06
  • @DanM. I don't understand. If you want the builtin time, run time. If you want the standalone executable, run /usr/bin/time.
    – terdon
    Sep 26, 2019 at 12:10
  • there is no built-in time on Ubuntu's default shell as far as I'm aware. I want to translate script using built-in into standalone with the same behavior.
    – Dan M.
    Sep 26, 2019 at 12:13
  • @DanM. then just use time. It will call whichever one is available. That will be the builtin for bash and the standalone for dash. If you use /usr/bin/time, then it will always call the standalone, both in bash and in dash. But it sounds like you should probably be asking a new question, explaining the behavior you need. Let me know if you do and I'll try and help.
    – terdon
    Sep 26, 2019 at 12:18
  • yeah, but built-in and standalone have drastically different syntax/semantics. Anyway, thanks. I'll ask a new question if I won't figure out how to deal with it myself.
    – Dan M.
    Sep 26, 2019 at 12:31

The bash and zsh shells have their internal time command. You have to use

/usr/bin/time -f ...

BTW, I discovered that using (from zsh):

~% which  time
time: shell reserved word

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .