Quickly find and understand file differences from the shell. 16.11.2025 | reading time: 2 min When you need to see what changed between two files, `diff` is the classic command-line tool that shows line-by-line differences; it helps track edits, build patches, and automate checks. Track edits in configs Create two small config files and compare them: ``` echo 'server=10.0.0.1' > a.conf echo 'server=10.0.0.2' > b.conf echo 'timeout=30' >> a.conf echo 'timeout=30' >> b.conf ``` Now run a unified diff to see the exact change: ``` diff -u a.conf b.conf --- a.conf +++ b.conf @@ -1,2 +1,2 @@ -server=10.0.0.1 +server=10.0.0.2 timeout=30 ``` Options that matter Learn a few common flags by doing: `-u` produces unified context, `-y` shows side-by-side, `-r` recurses into directories, `-i` ignores case and `-b` ignores changes in amount of whitespace; for example `diff -y a.conf b.conf` gives a quick visual alignment of changed lines. Automate and patch Turn a difference into a patch and apply it: `diff -u original new > change.patch` then `patch -p0 < change.patch`; use `diff` exit codes in scripts (0 identical, 1 different, 2 error) and `diff -r` to compare directory trees when preparing backups or deployments. Complementary tools `diff` is compact, but sometimes you want color, word-level diffs or integration: use `colordiff` for readable output, `wdiff` to compare words instead of lines, `vimdiff` or `meld` for interactive merges, and of course `git diff` when working with repositories. Next steps Start using `diff` in inspections, CI checks and patch workflows and then level up: learn more about LINUX and consider preparing for CompTIA Linux+ or LPIC-1 exams with intensive exam preparation at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. utilities version-control scripting troubleshooting filesystem