About Linux FAQ

Browse More FAQs:

Howto apply a patch file to my Linux / UNIX source code

Posted by Vivek Gite [Last updated: April 24, 2007]

Q.I know that I can patch binary package using up2date or yum command in Linux but what I’m wondering is if there’s a way to apply a patch file to downloaded source code under Linux / UNIX like operating system source tree?

A. Linux and UNIX source software often comes with security and other patches. You can download them from Internet or project home page. There is a command called patch that apply a diff file or patch to an original source tree.

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.

The following usage is most commonly used:
$ patch -p1 < {/path/to/patch/file}

To apply a patch, one could run the following command in a shell:
$ patch < /path/to/file

Patches can be undone, or reversed, with the '-R' option:
$ patch -R < /path/to/file

Above 3 are basic usage read the man page of patch command for more information and usage:
% man patch

Capture each and every moment of life with a FREE 4 GB SD memory card with the purchase of select digital cameras from Canon, Nikon, Pentax and others from Amazon

E-mail    Print    Can't find an answer to your question? Contact us

Related Other Helpful FAQs:

Discussion on This FAQ

  1. naresh Says:

    Linux and UNIX source software often comes with security and other patches. You can download them from Internet or project home page. There is a command called patch that apply a diff file or patch to an original source tree.

    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.

  2. naresh Says:

    guess what I need is a link to the .patch file syntax so I know what it means and can apply the changes manually (unless there’s some other way to do it).

Leave a Reply

We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Copyright © 2006-2008 nixCraft. All rights reserved - TOS/Disclaimer - Privacy policy - Powered by Open source software.