Table of Contents
Linux Time Command
Time command in Linux is used to determine total execution time of the given command. Mainly used to check the performance of commands and scripts. Using Time command you can also compare total download time for a file using
curl commands. In this tutorial, you are going to learn Linux
time Command with Examples.
Basic Syntax of Time Command
Following is the basic syntax for
time command in Linux:
time [-p] command [arguments...]
-p: to print time summary in POSIX form this option is used.
Time Command Versions
Linux shells like Bash, Zsh both have their own version of
time command which takes precedence over GNU time command. So to check whether you are using
GNU time time command or not use the following command:
The output should be one of the following:
# GNU time (sh) time is /usr/bin/time # Bash time is a shell keyword # Zsh time is a reserved word
If you didn’t get output like
time is /usr/bin/time then you should use time command like given below. specifying the full path.
Now check the type, you will get
time is /usr/bin/time as output.
Time Command Examples
Following are the examples for
Check time taken by the
To check time taken by
df command to show free disk space run below command:
The output should be:
Filesystem 1K-blocks Used Available Use% Mounted on udev 3941960 0 3941960 0% /dev tmpfs 794444 1896 792548 1% /run /dev/sda5 51343748 6024104 42681828 13% / tmpfs 3972204 111068 3861136 3% /dev/shm tmpfs 5120 4 5116 1% /run/lock tmpfs 3972204 0 3972204 0% /sys/fs/cgroup /dev/sda6 82045336 2879060 74955588 4% /home /dev/sda2 98304 30413 67891 31% /boot/efi tmpfs 794440 16 794424 1% /run/user/120 tmpfs 794440 32 794408 1% /run/user/1000 real 0m0.004s user 0m0.003s sys 0m0.001s
Check time taken by the
To check the execution time for wget command for downloading Google Chrome setup file run below command:
time wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
The last portion of output should look like:
2019-02-26 23:21:35 (878 KB/s) - ‘google-chrome-stable_current_amd64.deb’ saved [57089254/57089254] + Done time wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb?src=0 real 1m4.812s user 0m1.627s sys 0m4.346s
real: The time from start to finish. (starts when ENTER is pressed)
user: The total amount of CPU time used in User Mode.
sys: The total amount of CPU time used in Kernel Mode.