The diff command is used for creating a patch file. For this you will have an Original file, Modified file and finally we will create a Patch file with these 2 files. Diff command to create a patch file. # diff -u original.txt updated.txt > patch.txt Here -u represents the unified file. Now applying the patch by the below command. # patch original.txt < patch.txt This will replace the original file with the modifications. For Undo / Reverse the applied patch. # patch -R original.txt < patch.txt This will undo all the patches first applied.