Quick-n-Dirty Guide to Creating and Applying diff-style Patches 1) DO YOU HAVE DIFF AND PATCH? ------------------------------ In a shell, type: which diff which patch This should return the paths to diff and patch, probably /usr/bin/diff and /usr/bin/patch, respectively. If it finds them, continue to Step 2. If it does not, you have a serious problem, as diff and patch are two of the most fundamental utilities in a Unix system. Hopefully, your $PATH environment variable just does not contain the proper paths to the binaries. Try typing in a shell: for i in /bin /usr/bin /usr/local; do find $i -name diff find $i name patch done If this returns a full path to diff and patch, note that path, then add it to your $PATH by typing: export PATH=$PATH:diff_path:patch_path where diff_path is the path to the diff binary (take the /diff off the end of what the find command reported for diff) and patch_path is the path to the patch binary (take the /patch off the end of what the find command reported for patch). Now, repeat this step, and the 'which' commands should find both diff and patch. If they do, continue to Step 2. If not, try contacting your local LUG for help. *** Link to the Help Me! QND *** 2) CREATING PATCHES WITH DIFF ----------------------------- In a shell, change to the directory where the file you wish to make a patch for is located. Copy the original file (before your edits) to the same directory (you *did* make a backup copy of it before you edited it, right?). Now, type in the shell: diff -uN original_file new_file >patch.original_file where original_file is the filename of the original file and new_file is the filename of the new file (the one containing your edits). This technique also works for creating a patch for a whole directory tree (e.g. creating a Linux kernel patch). Just add the -r flag to your diff command: diff -uNr original_dir new_dir >patch.original_dir Here is a concrete example of creating a patch against the vanilla Linux kernel's source tree: cd /usr/src diff -uNr linux-2.4.19 linux-2.4.19-my_version \ >patch.linux-2.4.19-my_version That is all there is to creating patches with diff. Move on to Step 3 to see how to apply them with patch. 3) APPLYING PATCHES WITH PATCH ------------------------------ Copy the patch that you generated in Step 2 to the directory containing the file to which you want to apply the patch. Now, type in your shell: patch