watch command

monitors changes in command output

Typical usage: diagnosing problems, monitoring, troubleshooting

Introduction into watch

The watch command is one of those small Linux utilities that come in handy at times. It runs a command with a specified interval and shows its output. This is useful during troubleshooting, for example when you are interested in monitoring a directory for changes. Although you can define a ‘watch’ with the Linux Audit Framework, it is quicker to run this command instead.

Installation

When watch is not installed by default, it can be added to the system using the relevant software package.

Package information for watch

Operating systemPackage nameInstallation
AlmaLinuxprocps-ng
dnf install procps-ng
Arch Linuxprocps-ng
pacman -S procps-ng
Debianprocps
apt install procps
Fedoraprocps-ng
dnf install procps-ng
Red Hat Enterprise Linuxprocps-ng
dnf install procps-ng
Rocky Linuxprocps-ng
dnf install procps-ng
openSUSEprocps
zypper install procps
Ubuntuprocps
apt install procps

Your Linux distribution using a different package? Share your feedback.

Usage

Available options

Long optionShort optionDescription
--beep-bBeep on error (based on exit code)
--differences[=permanent]-dShow the differences in output. When using the optional '=permanent', the differences between the original output and last refresh will stay marked.
--no-title-tDon't use header with title, refresh interval, so only command output remains
--no-wrap-wNo wrapping of lines that are too long
--version-vShow version information

Missing an option in this overview? Share your feedback.

Examples using watch

File systems and directories

Show differences within a directory, mark items that changes

watch --differences=permanent ls -l

Monitor directory with most recently changed files on top

watch ls -alt

Monitor available disk space, especially useful during batch operations

watch df -h

Monitor current directory size (in megabytes)

watch du -sm

Monitor if a mount point is still in use

watch fuser --verbose --mount /mnt/backups

Networking

Show network connection statistics with a refresh every second

watch --interval=1 ss -s

Hardware

Monitor temperature changes (requires sensors command)

watch sensors

Frequently Asked Questions

What is the watch command and its purpose?

The watch command is a command-line tool to watch changes in the output of commands to assist with monitoring and troubleshooting.

Which package provides the watch command?

The command watch is provided by the procps or procps-ng package.

Related and similar commands

Linux has a lot of tools and commands available and sometimes you just need that little other tool. Here is a list of commands that are similar or related to watch:

Related and similar commands to watch
CommandCategorySummary
basenamefilesStrips directory and file name suffix from a given path
chrtprocessesSets Linux scheduler policy and priority for a process or command
fuserfiles and socketsShow processes using a file or socket
killprocessesSending signals to processes
lsfdfilesShows open file descriptors for processes
niceprocessesRuns commands with specified priority
numactlprocessesControls NUMA policy for processes and shared memory
peekfdprocessesTracks a process and show file descriptor activity
pidofprocessesReturns process IDs for a process name
pidstatmonitoringMonitoring CPU, memory, and disk activity
pidwaitprocessesWait for process to stop
pmapprocessesShows memory mapping of process
prtstatprocessesShows process details for selected process like state, CPU and memory usage
pscapcapabilitiesDisplay available capabilities for running processes
pslogloggingShows which log files a process has opened
pstreeprocessesShow active processes and children like a tree
pwdxprocessesShows current working directory of a process
reniceprocessesChanges the priority of running processes
slabtopmemoryShows slab usage of kernel
smemmemoryShow memory usage including swap
straceprocess inspectionInspects running process
unitsdata conversionConverts a unit into another one, like from Celcius to Fahrenheit