<?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=DIFF_-_Basic_Documentation</id>
	<title>DIFF - Basic Documentation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://it-arts.net/index.php?action=history&amp;feed=atom&amp;title=DIFF_-_Basic_Documentation"/>
	<link rel="alternate" type="text/html" href="https://it-arts.net/index.php?title=DIFF_-_Basic_Documentation&amp;action=history"/>
	<updated>2026-05-02T18:29:45Z</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=DIFF_-_Basic_Documentation&amp;diff=904&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=DIFF_-_Basic_Documentation&amp;diff=904&amp;oldid=prev"/>
		<updated>2026-01-17T07:08:18Z</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 07:08, 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 diff 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 diff 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=DIFF_-_Basic_Documentation&amp;diff=790&amp;oldid=prev</id>
		<title>Admin: Created page with &quot;Category:Wiki  == Common diff Command Use Cases ==  === Compare Two Files Line by Line === To compare two files and show the differences between them:   &lt;nowiki&gt; diff file1.txt file2.txt&lt;/nowiki&gt;  This command compares `file1.txt` and `file2.txt` line by line, displaying the differences in a unified format by default.  === Show Differences Side by Side === To display the differences between two files side by side:   &lt;nowiki&gt; diff -y file1.txt file2.txt&lt;/nowiki&gt;  The...&quot;</title>
		<link rel="alternate" type="text/html" href="https://it-arts.net/index.php?title=DIFF_-_Basic_Documentation&amp;diff=790&amp;oldid=prev"/>
		<updated>2026-01-12T20:25:01Z</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 diff Command Use Cases ==  === Compare Two Files Line by Line === To compare two files and show the differences between them:   &amp;lt;nowiki&amp;gt; diff file1.txt file2.txt&amp;lt;/nowiki&amp;gt;  This command compares `file1.txt` and `file2.txt` line by line, displaying the differences in a unified format by default.  === Show Differences Side by Side === To display the differences between two files side by side:   &amp;lt;nowiki&amp;gt; diff -y file1.txt file2.txt&amp;lt;/nowiki&amp;gt;  The...&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 diff Command Use Cases ==&lt;br /&gt;
&lt;br /&gt;
=== Compare Two Files Line by Line ===&lt;br /&gt;
To compare two files and show the differences between them:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command compares `file1.txt` and `file2.txt` line by line, displaying the differences in a unified format by default.&lt;br /&gt;
&lt;br /&gt;
=== Show Differences Side by Side ===&lt;br /&gt;
To display the differences between two files side by side:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff -y file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The `-y` option shows the differences between `file1.txt` and `file2.txt` side by side, which makes it easier to compare the files visually.&lt;br /&gt;
&lt;br /&gt;
=== Ignore Whitespace Differences ===&lt;br /&gt;
To ignore changes in whitespace (spaces or tabs) when comparing files:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff -w file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The `-w` option ignores all white space, making the comparison more focused on actual content differences rather than formatting.&lt;br /&gt;
&lt;br /&gt;
=== Show Only the Differences, Without Context ===&lt;br /&gt;
To display only the lines that differ between two files, without any additional context:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff -u file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The `-u` option shows a unified diff, which includes a few lines of context before and after each difference to make the comparison clearer.&lt;br /&gt;
&lt;br /&gt;
=== Compare Directories Recursively ===&lt;br /&gt;
To compare two directories and show the differences in files within them:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff -r dir1/ dir2/&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The `-r` option allows `diff` to recursively compare all files in `dir1/` and `dir2/`, including subdirectories.&lt;br /&gt;
&lt;br /&gt;
=== Output Differences in a Machine-Readable Format ===&lt;br /&gt;
To generate a machine-readable output, useful for scripting or automation:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff -u file1.txt file2.txt &amp;gt; differences.patch&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The `-u` option generates a unified diff output, which is commonly used for patches. This can be redirected to a file (`differences.patch`) for future use.&lt;br /&gt;
&lt;br /&gt;
=== Compare Files Using a Specific Character Set (Locale) ===&lt;br /&gt;
To compare files using a specific locale or character set:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff --ignore-case file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command compares `file1.txt` and `file2.txt`, ignoring case differences between characters, making the comparison case-insensitive.&lt;br /&gt;
&lt;br /&gt;
== Advanced diff Command Options ==&lt;br /&gt;
&lt;br /&gt;
=== Show Line Numbers for Differences ===&lt;br /&gt;
To show the line numbers of the differences between files:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff -n file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The `-n` option adds line numbers to the output, allowing you to know exactly where the differences occur in the files.&lt;br /&gt;
&lt;br /&gt;
=== Report the Number of Differences ===&lt;br /&gt;
To only show the number of lines that are different between the files:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff -q file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The `-q` option reports only whether the files are identical or not, providing a concise result with no details about the specific differences.&lt;br /&gt;
&lt;br /&gt;
=== Compare Files with Context Lines ===&lt;br /&gt;
To show additional context before and after each difference, which helps when reviewing larger files:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff -C 5 file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The `-C 5` option shows 5 lines of context before and after each difference, providing more context to understand the changes in the files.&lt;br /&gt;
&lt;br /&gt;
=== Compare Files Using a Specific Algorithm ===&lt;br /&gt;
To specify the algorithm used to compare files, use the `--speed-large-files` option for faster comparisons with large files:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff --speed-large-files file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This option is helpful when working with very large files, as it speeds up the comparison process.&lt;br /&gt;
&lt;br /&gt;
=== Compare Files Without Producing Any Output (Silent Mode) ===&lt;br /&gt;
To perform the comparison but suppress any output unless there is a difference:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff -s file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The `-s` option ensures that `diff` reports &amp;quot;files are the same&amp;quot; if no differences are found.&lt;br /&gt;
&lt;br /&gt;
== Security Concepts ==&lt;br /&gt;
&lt;br /&gt;
=== Secure Comparison of Configuration Files ===&lt;br /&gt;
The `diff` command can be particularly useful for comparing configuration files, which often store sensitive system or network settings. By securely comparing files, you can identify unauthorized changes or inconsistencies.&lt;br /&gt;
&lt;br /&gt;
For example, comparing `/etc/ssh/sshd_config` across multiple systems:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff /etc/ssh/sshd_config system1_ssh_config&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This helps identify differences that may affect system security, such as changes to login restrictions or allowed authentication methods.&lt;br /&gt;
&lt;br /&gt;
=== Detecting Changes in Log Files ===&lt;br /&gt;
`diff` is also useful for detecting changes between two versions of log files, helping administrators identify potential security breaches or unauthorized actions.&lt;br /&gt;
&lt;br /&gt;
For example, comparing log files:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff /var/log/auth.log /var/log/auth.log.old&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This comparison can reveal new failed login attempts or unauthorized access patterns in the logs.&lt;br /&gt;
&lt;br /&gt;
=== Verifying File Integrity with Diff ===&lt;br /&gt;
You can use `diff` to check for unauthorized changes to critical files, ensuring the integrity of the files by comparing the current version with a known good version.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff /etc/hosts /etc/hosts.backup&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This command compares the current `/etc/hosts` file with a backup, identifying any changes that might indicate tampering.&lt;br /&gt;
&lt;br /&gt;
=== Ensure Consistency Between Files on Multiple Systems ===&lt;br /&gt;
When managing multiple systems, it’s crucial to ensure that configuration files or critical system files are identical across all systems. Use `diff` to verify consistency between files.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff /etc/network/interfaces system1_interfaces&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This checks if the network configuration files are the same across systems.&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
=== No Output When Files Are the Same ===&lt;br /&gt;
If `diff` produces no output and you expect differences, check if the files are actually identical or if any invisible characters (like whitespace or newlines) are causing discrepancies. Use the `-w` option to ignore whitespace differences:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff -w file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will ignore any differences in whitespace.&lt;br /&gt;
&lt;br /&gt;
=== Files Not Displaying All Differences ===&lt;br /&gt;
If `diff` isn&amp;#039;t displaying all the expected differences, check if you are using an appropriate option to reveal context or show more lines before and after differences. Use `-C` for more context:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff -C 5 file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This shows 5 lines of context before and after each difference.&lt;br /&gt;
&lt;br /&gt;
=== Comparing Large Files Takes Too Long ===&lt;br /&gt;
For very large files, the comparison might take a long time. Consider using the `--speed-large-files` option to speed up the process for large files:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff --speed-large-files file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This speeds up comparisons of large files by using a different comparison algorithm.&lt;br /&gt;
&lt;br /&gt;
=== Permission Denied When Using diff ===&lt;br /&gt;
If you encounter permission issues when comparing files, ensure that you have the appropriate permissions to read both files. Use `sudo` if necessary:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
sudo diff file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This ensures you have the necessary privileges to compare files that require elevated permissions.&lt;br /&gt;
&lt;br /&gt;
=== Incorrect Output Format ===&lt;br /&gt;
If `diff` produces output in a format that isn&amp;#039;t what you expected, ensure that you&amp;#039;re using the correct options for your desired output format. For example, use `-u` for a unified diff:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;&lt;br /&gt;
diff -u file1.txt file2.txt&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will show differences in a unified format, which is more readable and typically used for patch creation.&lt;br /&gt;
&lt;br /&gt;
== Useful Links ==&lt;br /&gt;
&lt;br /&gt;
* https://man7.org/linux/man-pages/man1/diff.1.html&lt;br /&gt;
* https://www.gnu.org/software/diffutils/manual/diffutils.html&lt;br /&gt;
* https://linux.die.net/man/1/diff&lt;br /&gt;
* https://www.gnu.org/software/diffutils/&lt;br /&gt;
* https://www.ibm.com/docs/en/aix/7.2?topic=commands-diff&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>