• 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

The Watch Command: Everything You Need To Know

Benjamin O'Donald

Published on: January 29, 2025

Categories: Linux Command Line 0

Table of Contents
  • What is watch?
  • Basic Linux watch command syntax
  • Basic usage of the watch command
    • Checking version information
    • Watch options command
    • Using a standard watch command with no options
    • Setting a custom time interval
    • Showing changes between update intervals
    • Turn off the header from a watch command
    • Piping multiple commands into watch
    • Combining watch with the tail command
    • Have the watch command exit on change of output
    • Having the watch command display colored output
    • Have the watch command alert you for file changes
  • Conclusion

What is watch?

The Linux watch command line utility is installed by default and it allows for real time system monitoring on the command line interface.

This command allows for you to monitor command output in regular intervals and during each interval the output of your command refreshes.

In the past I’ve personally used the watch command many times to monitor system resource usage during various tasks.

For example I have used watch to monitor disk usage while an rsync command was running in the background on a server.

This was very useful at the time as it helped in preventing the disk from reaching full capacity during the file copy since the command periodically would show the updated disk usage.

During that if the disk space reached close to 100% I was able to see this while using watch and then could cancel the rsync. After that I’d be able to explore other options for how to proceed with the sync, such as cleaning up the disk before running it again.

The Linux watch command can be used in combination with tons of other commands so it can be crafted to suite your specific needs.

In this article we’ll be covering the basic usage of the watch command, the common watch command options, and practical examples of how we can combine multiple commands with watch.

Basic Linux watch command syntax

The basic syntax for using the watch command is pretty straight forward. Overall you will use ‘watch’ in the beginning of a command followed by an option and then the command you’d like to watch.

Such as in this example:

$ watch [options/flags] [command to watch]

Basic usage of the watch command

Checking version information

You can view the version installed with the following command:

$ watch -v

Watch options command

You can always check the ‘man pages’ for more information on the options offered with watch but you’re also able to just run the following watch options command:

$ watch -h

Using a standard watch command with no options

Let’s say you want to monitor disk usage during a file copy to make sure the disk doesn’t reach 100% capacity.

In such an example you could use this simple watch command without any flags/options and by default it will refresh the command output every two seconds:

$ watch df -h

Setting a custom time interval

On the other hand lets say you want to have the watch command update the output every 5 seconds rather than the two second default.

In this case you could set a custom time interval to update a commands output with use of the -n flag which is used for setting the desired time interval for the refresh rate.

Using the following specified command in terminal would watch the ‘df -h’ command and refresh it’s output every 5 seconds since we’re setting -n to 5:

$ watch -n5 df -h

The output of the above disk space command would show the following output:

In the output displayed above we see the watch command header showing the refresh rate or update interval (5 seconds), hostname of your system, current system date, and then output of the df -h command we ran with watch.

Showing changes between update intervals

You can also have the command show changes between each update interval with use of the -d (–difference) option/flag.

With the specified command we will see that during each update it will highlight changes within a free -m command where we’re monitoring memory usage:

$ watch -d free -m

From the below screen shots which were taken at 3 different update intervals we see how the command highlights differences between each refresh interval:

Shown above we see that in each screen shot the command updates us at each interval by highlighting the changes in values.

Above it shows the memory “used” changes are being highlighted at each interval while the value fluctuates from 13,443MB to 13,460MB and then to 13,462MB.

Turn off the header from a watch command

If would prefer to turn off the header included in your output while using watch you can use the -t flag.

So as example in this command (before using -t) we see the time update interval at the top, command running, system name, and current time when using free -m to monitor memory usage:

$ watch free -m

And now when we add in the -t flag we will see how that information is removed from the displayed output:

$ watch -t free -m

Piping multiple commands into watch

In the below example we’ll combine a couple commands with watch to monitor processes running under a specific user named “bodonald”:

$ watch "ps faux | grep bodonald"

Combining watch with the tail command

To expand a bit further on the previous section we’ll combine ls and tail into a watch command to view the most recent files in a directory:

$ watch "ls -ltr /home/bodonald/Downloads | tail -20"

Have the watch command exit on change of output

There could be instances where you’d want to use watch to monitor a command but then exit if the output changes from that command.

This can be done when utilizing the -g flag in a watch command such as below:

$ watch -g df -h

From the above using -g in this example will cause the command to exit once the output of ‘df -h’ changes.

Having the watch command display colored output

Depending on your terminal settings you can have watch display its output in color with use of the -c option/flag such as in the following example where we’re monitoring memory usage:

$ watch -c free -m

This personally does not work for me as I do have a custom theme and colors set for my terminal profile but if you’re using the default settings this would alter the output to show in color.

Have the watch command alert you for file changes

Below is a simple ls command with watch but we’ll be adding in the -b flag which alerts you with a “beep” noise if changes are detected on files within the /home/user/html directory:

Note: the “beep” alert only works if the beep package is installed

$ watch -b ls -lah /home/user/html

Conclusion

Within Linux it can be very useful to have the watch command in your tool belt. There are many different use cases for watch and it can be crafted into more complex commands to suite your needs.

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 the Tee Command in Linux

The tee command in Linux is useful when you want to direct the output of a command to multiple locations. Here's how to use it.

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. […]

How to Use set -e -o pipefail in Bash, and Why

While writing scripts in bash, it's important to be careful about error handling. That's what set -e -o pipefail does.

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