In some cases you might find yourself in need to apply a patch or change a compile time configuration option for a package you installed from the repository. It's easy to do that, as tools are available to download the source of a package and recompile it after you have made the changes you need.
sudo apt-get update
As always, before you install packages from the terminal do an update first so that your local package cache is in sync with the repository.
sudo apt-get install build-essential devscripts
Installs the base compiler toolchain.
Open Software Sources from your menu, and make sure "Enable source code repositories" is marked. Then click "Update the cache".
This allows for downloading source for packages.
Recompiling from source
apt-get source package
Downloads the source for a package to your current directory. Replace package with the name of the package you want to download the source for. Mind that you must not use sudo!
dpkg-source -x filename.dsc
Extracts the source. Replace filename.dsc with the name of the downloaded .dsc file. You can look in your file manager, or with a command like ls *.dsc to find that.
Change directory to the newly created source directory. Replace dirname with the name of the extracted directory. You can look in your file manager, or with a command like ls -l to find that.
sudo apt-get build-dep package
installs the build time dependencies needed to compile the package from source. Replace package with the same name as used in step 1.
You can now apply any patches you need or change any compile time configuration options. That's a manual step that I can't generalize in this tutorial. Recommend you keep the terminal open on the current directory, and use another terminal if needed for doing modifications.
debuild -us -uc
Recompiles the package.
Goes one directory up, as here you will find your newly created package.
sudo dpkg -i filename.deb
Installs the recompiled package. Replace filename.deb with the name of the created .deb file. You can look in your file manager, or with a command like ls *.deb to find that.
Cleanup consists of deleting the downloaded files, the extracted source code directory, and the created recompiled package.