<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://it-arts.net/index.php?action=history&amp;feed=atom&amp;title=WATCH_-_Command_Examples</id>
	<title>WATCH - Command Examples - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://it-arts.net/index.php?action=history&amp;feed=atom&amp;title=WATCH_-_Command_Examples"/>
	<link rel="alternate" type="text/html" href="https://it-arts.net/index.php?title=WATCH_-_Command_Examples&amp;action=history"/>
	<updated>2026-05-02T18:43:02Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://it-arts.net/index.php?title=WATCH_-_Command_Examples&amp;diff=995&amp;oldid=prev</id>
		<title>Admin: Text replacement - &quot;Category:Wiki&quot; to &quot;Category:Wiki

&#039;&#039;&#039;&#039;&#039;[https://it-arts.net/index.php/Category:Wiki Return to Wiki Index]&#039;&#039;&#039;&#039;&#039;
&quot;</title>
		<link rel="alternate" type="text/html" href="https://it-arts.net/index.php?title=WATCH_-_Command_Examples&amp;diff=995&amp;oldid=prev"/>
		<updated>2026-01-17T08:12:50Z</updated>

		<summary type="html">&lt;p&gt;Text replacement - &amp;quot;&lt;a href=&quot;/index.php/Category:Wiki&quot; title=&quot;Category:Wiki&quot;&gt;Category:Wiki&lt;/a&gt;&amp;quot; to &amp;quot;&lt;a href=&quot;/index.php/Category:Wiki&quot; title=&quot;Category:Wiki&quot;&gt;Category:Wiki&lt;/a&gt;  &amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039;[https://it-arts.net/index.php/Category:Wiki Return to Wiki Index]&amp;#039;&amp;#039;&amp;#039;&amp;#039;&amp;#039; &amp;quot;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:12, 17 January 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Wiki]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Wiki]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&#039;&#039;&#039;&#039;&#039;[https://it-arts.net/index.php/Category:Wiki Return to Wiki Index]&#039;&#039;&#039;&#039;&#039;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Common watch Command Use Cases ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Common watch Command Use Cases ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://it-arts.net/index.php?title=WATCH_-_Command_Examples&amp;diff=788&amp;oldid=prev</id>
		<title>Admin: Created page with &quot;Category:Wiki  == Common watch Command Use Cases ==  === Monitor Command Output at Regular Intervals === To run a command at regular intervals (default: every 2 seconds) and display the output:   &lt;nowiki&gt; watch df -h&lt;/nowiki&gt;  This command runs `df -h` every 2 seconds, showing disk usage in human-readable format.  === Monitor a Specific File for Changes === To monitor a file for changes, such as its content or size:   &lt;nowiki&gt; watch ls -l /var/log/syslog&lt;/nowiki&gt;  Th...&quot;</title>
		<link rel="alternate" type="text/html" href="https://it-arts.net/index.php?title=WATCH_-_Command_Examples&amp;diff=788&amp;oldid=prev"/>
		<updated>2026-01-12T20:14:34Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/index.php/Category:Wiki&quot; title=&quot;Category:Wiki&quot;&gt;Category:Wiki&lt;/a&gt;  == Common watch Command Use Cases ==  === Monitor Command Output at Regular Intervals === To run a command at regular intervals (default: every 2 seconds) and display the output:   &amp;lt;nowiki&amp;gt; watch df -h&amp;lt;/nowiki&amp;gt;  This command runs `df -h` every 2 seconds, showing disk usage in human-readable format.  === Monitor a Specific File for Changes === To monitor a file for changes, such as its content or size:   &amp;lt;nowiki&amp;gt; watch ls -l /var/log/syslog&amp;lt;/nowiki&amp;gt;  Th...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Wiki]]&lt;br /&gt;
&lt;br /&gt;
== Common watch Command Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Monitor Command Output at Regular Intervals ===&lt;br /&gt;
To run a command at regular intervals (default: every 2 seconds) and display the output:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch df -h&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command runs `df -h` every 2 seconds, showing disk usage in human-readable format.&lt;br /&gt;
&lt;br /&gt;
=== Monitor a Specific File for Changes ===&lt;br /&gt;
To monitor a file for changes, such as its content or size:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch ls -l /var/log/syslog&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command runs `ls -l` on the specified file (`/var/log/syslog`), displaying its file attributes and any changes every 2 seconds.&lt;br /&gt;
&lt;br /&gt;
=== Change the Interval Between Command Executions ===&lt;br /&gt;
To change the default 2-second interval between executions:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch -n 5 df -h&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This runs `df -h` every 5 seconds instead of the default 2-second interval.&lt;br /&gt;
&lt;br /&gt;
=== Monitor Multiple Commands Simultaneously ===&lt;br /&gt;
To execute multiple commands in sequence and monitor their output:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch &amp;#039;date; uptime; free -h&amp;#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command runs `date`, `uptime`, and `free -h` sequentially every 2 seconds, showing the current time, system uptime, and memory usage.&lt;br /&gt;
&lt;br /&gt;
=== Run a Command Once and Exit after a Period ===&lt;br /&gt;
To run a command only for a specified duration and then exit:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch -t -n 10 df -h&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command will run `df -h` every 10 seconds for a total of 10 seconds, then exit.&lt;br /&gt;
&lt;br /&gt;
=== Highlight Changes in Command Output ===&lt;br /&gt;
To highlight the differences between successive outputs:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch -d df -h&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The `-d` option highlights the differences in the output between each execution, making it easy to track changes.&lt;br /&gt;
&lt;br /&gt;
=== Monitor File System Usage with Specific Criteria ===&lt;br /&gt;
To check for file system usage and highlight any changes in real-time:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch -d &amp;#039;df -h | grep /dev/sda1&amp;#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This runs `df -h`, but filters for the file system mounted on `/dev/sda1`, highlighting any changes.&lt;br /&gt;
&lt;br /&gt;
== Advanced watch Command Options ==&lt;br /&gt;
&lt;br /&gt;
=== Watch for Output of a Command with Color ===&lt;br /&gt;
To display the output with color support (if supported by the command):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch -c ls --color=auto&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command will execute `ls --color=auto`, which displays files and directories with color in the output.&lt;br /&gt;
&lt;br /&gt;
=== Customize the Watch Header ===&lt;br /&gt;
To customize or disable the header (showing the interval and command being executed):&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch -t df -h&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The `-t` option disables the default header in the output, showing only the results of the command.&lt;br /&gt;
&lt;br /&gt;
=== Use watch with Complex Commands or Scripts ===&lt;br /&gt;
To execute and watch complex shell commands or scripts:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch &amp;#039;echo &amp;quot;Disk space:&amp;quot;; df -h&amp;#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command executes a more complex script or series of commands, displaying both text (`Disk space:`) and command output.&lt;br /&gt;
&lt;br /&gt;
=== Monitor System Processes or Specific Process Information ===&lt;br /&gt;
To monitor the output of process-related commands:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch -n 1 &amp;#039;ps aux | grep apache2&amp;#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This runs `ps aux | grep apache2` every second to monitor the `apache2` process.&lt;br /&gt;
&lt;br /&gt;
=== Watch System Resource Usage with Graphical Representation ===&lt;br /&gt;
To monitor resource usage with a graphical representation:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch -n 1 &amp;#039;vmstat 1&amp;#039;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command continuously runs `vmstat 1`, showing a real-time snapshot of system performance.&lt;br /&gt;
&lt;br /&gt;
== Security Concepts ==&lt;br /&gt;
&lt;br /&gt;
=== Monitoring System Resources for Security Threats ===&lt;br /&gt;
The `watch` command can be used to monitor system resources, such as CPU, memory, and disk usage, which is useful for detecting unusual activity indicative of a security breach.&lt;br /&gt;
&lt;br /&gt;
For example, checking for high memory usage can help detect potential DDoS attacks or resource exhaustion:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch free -h&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command monitors memory usage in real-time, helping identify unusual consumption patterns that might indicate a security issue.&lt;br /&gt;
&lt;br /&gt;
=== Monitoring Running Processes for Malicious Activity ===&lt;br /&gt;
By monitoring running processes, you can identify any unusual or unauthorized processes that might indicate a system compromise. For instance, watching the output of `ps aux` can reveal suspicious processes.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch &amp;#039;ps aux | grep root&amp;#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command continuously checks for processes running under the `root` user, which is useful for detecting unauthorized escalations or hidden rootkits.&lt;br /&gt;
&lt;br /&gt;
=== Monitor Changes in Log Files for Security Events ===&lt;br /&gt;
You can use `watch` to monitor log files for suspicious activity. For instance, monitoring `/var/log/auth.log` for failed login attempts:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch &amp;#039;tail -n 50 /var/log/auth.log | grep &amp;quot;Failed password&amp;quot;&amp;#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This continuously watches the `auth.log` file for failed SSH login attempts, helping to identify brute force attacks.&lt;br /&gt;
&lt;br /&gt;
=== Real-Time Monitoring of Security Tools ===&lt;br /&gt;
`watch` can be used to monitor outputs from security tools like `snort`, `fail2ban`, or `suricata` to track active security measures on the system.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
watch &amp;#039;fail2ban-client status sshd&amp;#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command shows the status of the `fail2ban` service for the `sshd` service, helping monitor if there are active bans on malicious IP addresses.&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
&lt;br /&gt;
* https://man7.org/linux/man-pages/man1/watch.1.html&lt;br /&gt;
* https://www.gnu.org/software/coreutils/manual/html_node/watch-invocation.html&lt;br /&gt;
* https://linux.die.net/man/1/watch&lt;br /&gt;
* https://www.howtogeek.com/66985/using-the-watch-command-to-monitor-linux-commands-in-real-time/&lt;br /&gt;
* https://opensource.com/article/19/3/monitor-linux-commands-watch&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>