Correct way to apply patches to your kernel?
You need to download the source. You can do this via apt-src but I would (personally) just grab the latest from kernel.org, extract it, patch it (just using local paths like the desktop, it doesn't need to be hidden in /usr/src at all!) and follow the "old fashioned way" instructions for compiling it.
Note that some patches are only for certain versions of the kernel (this includes point releases) so make sure your patch works for the source version before you waste 20-30 minutes compiling it.
But your specific problem is you need to be in the directory that you want to apply the patch to. In your case:
cd /usr/src/linux-headers-2.6.35.22/
patch -p1 < /path/to/file.diff
Obviously change the path to the patch (or stick it in the same directory). If the source files are owned by root, prefix sudo
onto the patch command or run sudo su
to become root while you do this.
To avoid frustration, you should generally do such things the Ubuntu way. Full instructions using official packages can be found here:
https://help.ubuntu.com/community/Kernel/Compile
It provides lists of dependencies and step-by-step commands for getting a custom kernel up and running.
By following that procedure, you will end up with an uninstallable package containing your custom kernel, which means that you will be able to switch back to the official kernels in future if needed.
The instructions you are following are showing you the command-line prompt /usr/src/linux #
, which is not something you type as part of the command. The command to type that will apply the patch starts at patch
and continues from there.