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
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop













{ 5 comments… read them below or add one }
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.
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).
Hi
I want to merge two patch file into one then how I can get that done without any complications and breaking the source.If I apply both separately then it fails.
I have yet to see Wine Internet Explorer , wine-1.3.6 I can click on the white loading bar while new Adobe FlashPlayer 11beta for Internet Explorer (only) is trying to load it in my terminal thru (Wine Windows Program Loader) and Wine Internet Explorer will power-up, but its missing a few stuff. Adobe FP 11b not right one for it (because the accept license agreement tab not there) and wish someone could find right FP, maybe you or someday adobe will produce one? Check-it out and you will see! But the new Adobe Air 11b (IE only) loaded great.
Just For Information:
-p0 in patch command –> entire file name
-p1 in patch command –> file name preceding first forward slash
-p2 in patch command –> file name preceding second forward slash
etc.
Example:
-p0 = /path/to/patch/file
-p1 = path/to/patch/file
-p2 = to/patch/file
-p3 = patch/file
-p4 = file