My Tech notes: Working With Linux Patch 10 Step Guide

Unix Documentation

Free Online Unix Training Materials

Lists many links to free Unix training materials.

Pointers and Arrays Materials

Pointers and Arrays materials Explained for C beginners

C FAQ and General Questions C Interview Questions

Powered By

Free XML Skins for Blogger

Powered by Blogger

Tuesday, May 5, 2009

Working With Linux Patch 10 Step Guide

What is Linux patch ?
Here is patch description from Linux Man pages.
       patch - apply a diff file to an original

       patch [options] [originalfile [patchfile]]

       but usually just

       patch -pnum <patchfile

       patch  takes  a patch file patchfile containing a difference listing produced by the diff program and applies those
       differences to one or more original files, producing patched versions.  Normally the patched versions  are  put  in
       place  of the originals.  Backups can be made; see the -b or --backup option.  The names of the files to be patched
       are usually taken from the patch file, but if thereâs just one file to be patched it can specified on  the  command
       line as originalfile.

How Linux patch works?
Here is short explanation about How to use patches in linux.
Working with Patch 10 step Guide.
  1. mkdir patch_test
  2. cd patch_test/
  3. mkdir old
  4. cd old
  5. create   file1.txt and file2.txt
  6. cd .. ; mkdir new
  7. cp file.txt and file2.txt == Now change both or any files to create patch
  8. cd .. ; ls // new and old dir here
  9. diff -Naur old new > learn.patch  ==Your patch is ready.
  10. patch -p0 < learn.patch  == apply patch to old folder; you should be above old dir
How to Reverse patch applied?
In order to reverse the patch applied run following command.
patch -p 1 -R < learn.patch

No comments:

Post a Comment