Apply unified diffs to files, inspect changes, and recover when a patch refuses to apply. 20.04.2026 | reading time: 2 min The `patch` command takes a diff produced by `diff -u` and applies those changes to files so he can update source or configuration files without manual editing. Real patch example Follow these commands to create a tiny diff and apply it with `patch` so he sees the full cycle in action: ```bash cat > hello.txt <<'EOF' Hello world This is v1 EOF cat > hello.txt.mod <<'EOF' Hello world This is v2 EOF diff -u hello.txt hello.txt.mod > hello.patch patch < hello.patch patching file hello.txt cat hello.txt Hello world This is v2 ``` Options that matter Use `-pNUM` to strip path components so the patch finds files, run `--dry-run` to test application without changing files, and use `-R` to reverse a patch; `-b` makes backups and rejected hunks end up in `.rej` files when fuzz or context mismatches occur. Where patch fits `patch` is the classic tool for applying diffs created by `diff`; in modern workflows he will often see `git apply` or `git am` for repository patches and tools like `quilt` or `patchutils` to manage patch stacks and produce cleaner series. Final step Mastering `patch` helps him handle offline changes, forward-port fixes and manage archives of changes; keep practicing with diffs and consider formalizing skills by preparing for CompTIA Linux+ or LPIC-1, with intensive exam preparation available at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. utilities version-control scripting