• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero® Blog

NameHero® Blog

Web Hosting Tips & Resources From NameHero

  • AI Agents
    • OpenClaw
    • Claude Code
    • n8n
    • Hermes Agent
    • Open WebUI
    • Docker
  • Hosting
    • Web Hosting
    • WordPress Hosting
    • WooCommerce Hosting
    • Enterprise Hosting
    • Email Hosting
    • HeroicGuard
    • GPU Hosting
    • Website Builder
  • VPS
    • Managed VPS
    • Unmanaged VPS
    • Flex VPS
  • Reseller
  • Gaming
  • Domains
  • Account
  • Blog Home
  • Categories
  • Authors

Timing Your Shell Commands Using The Time Command In Linux

CJ Saathoff

Published on: May 22, 2024

Categories: Linux Command Line 0

Have you ever thought it would be nice to time a command? Do you end up taking out a stopwatch or your smartphone? I have good news… Linux has a command for that, the time command. The time command in Linux gives you the option to time command from the very shell you run the command from.

Table of Contents
  • What Is The Linux Time Command?
  • How Do I Get The Time Command?
  • Usage
  • Understanding the output
  • Examples
  • Conclusion
  • Additional Links

What Is The Linux Time Command?

Have you ever thought it would be nice to time a command? Do you end up taking out a stopwatch or your smartphone? The time command in Linux is used to measure command execution time from the very shell you run the command from.

How Do I Get The Time Command?

On most Linux distributions the time command is pre-installed. If you find it isn’t preinstalled try searching for the package by the name of your package manager. If neither of these works please refer to your Linux Distributions documentation.

Be aware both Bash and Zsh have built-in versions of the time command. These are both separate from the Upstream GNU version provided by the free software foundation.

Usage

Ok, so you have a command you want to time, for example, it could be that a command is taking a while, or could be as simple as wanting to have numbers on how long a command takes.

To measure execution time for a command replace command in the following command:

time command

Note: The GNU version of the time command has many flags that can be used but is not universal compared to other versions of the time command. If you find yourself using GNU time be aware it is not universal and refer to the man page for flags.

Understanding the output

Below is the output you will get from the basic syntax.

real 0m0.000s

user 0m0.000s

sys 0m0.000s

The descriptions below explain what is being measured for each.

real – The Real-time is the execution time of the command from start to finish.

user – The user time is the CPU time spent executing system time.

sys – The system time is the time spent on system calls and the like.

Examples

Time the time it takes to recursively copy from one directory to another

time cp -r /source/directory /destination/directory

Time a script

time ./script.sh

Time and output the results of the ls command to a file

time ls > output.txt 2>&1

Time with a shell pipe

time (command1 | command2)

Time a MySQL query

time mysql -u username -p -e "SELECT * FROM table_name"

Conclusion

The time command is rather simple but simple isn’t a bad thing, as even the simplest Linux commands can be priceless. In this blog post, we have discussed what the time command is, that it should be available on almost all Linux distributions by default, how to use the command, and how to understand the resulting output. Finally ending on some examples of how you can use the time command with various other commands.

Additional Links

Want to read more about other Linux Commands check out our other posts.

  • Other Linux Command Posts
CJ Saathoff

Embracing a lifelong passion for technology since childhood, CJ delved into the intricate workings of systems, captivated by the desire to understand the unknown. This innate curiosity led to his discovery of Linux, a revelation that resonated deeply. With more than 7 years of on the job experience, he’s honed his technical skills as a Geek and Senior Linux Systems Administrator.

Related Posts

How to Use Git Rebase Interactive to Manage Commits

As a project progresses, commits can get messy. The git rebase interactive feature allows you to keep a clean commit history.

How to Use zsh Syntax Highlighting

In an earlier post, we discussed the basics of zsh, what it is, and how to get started. Today we’ll look at syntax highlighting in zsh, its meaning, and how to implement it. I’ll also explain why it doesn’t work well with bash, even though we can get it to work in a “hacky” way. […]

Using Bash Job Controls to Manage Multiple Processes

Bash job controls are used to send long running tasks into the background, and bring them forward when necessary.

Systemd Service File Example – How it Works

The service file manager in Linux - systemd - is configured using something called "unit files". Here's an example, and how it works.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!


Most Popular Posts

NameHero’s Recommended WordPress Plugin and Theme Setup

WordPress Hosting vs. Web Hosting – What’s The Difference?

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • WordPress Tutorials
  • OpenClaw Hosting
  • Enterprise Hosting
  • WooCommerce
  • Web Hosting
  • Resellers
  • Website Security
  • Website Development
  • Website Performance
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero® proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • Managed VPS Hosting
  • Unmanaged VPS Hosting
  • Flex VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • GPU Hosting
  • Email Hosting
  • HeroicGuard
  • Domains
  • Website Builder
  • AI Agent Hosting
Help & Support
  • NameHero Blog
  • NameHero Gaming Blog
  • Support
  • Help Center
  • Migrations
  • Affiliates
  • Gaming Affiliates
  • Call 1-855-984-6263
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2026 Name Hero, LLC. All rights reserved.
NameHero® is a registered trademark.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA