First, we need to add a third party repository to your /etc/apt/sources.list. (Help for this available at AddingRepositoriesHowto)
deb http://ppa.launchpad.net/amaranth/ubuntu feisty main
deb-src http://ppa.launchpad.net/amaranth/ubuntu feisty main
After adding the repository, we need to update our repositories and install it.
sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get install compiz compizconfig-settings-manager
If you are running Kubuntu then use this command
sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get install compiz compizconfig-settings-manager compiz-kde
Or you won't get any window decorations.
Run Compiz
To run Compiz for the current session, hold Alt, then press F2, then enter the command
compiz --replace
Configure
To configure Compiz and associated plugins, hold Alt, then press F2, then enter the command
ccsm
Alternatively, for Ubuntu: System -> Preferences -> CompizConfig Settings Manager
And for Kubuntu: KMenu > Settings > CompizConfig Settings Manager
Add Compiz to Gnome Startup (optional)
Go to System->Preferences->Desktop Effects and click 'Enable Desktop Effects'
Troubleshooting
If you ran nvidia-settings, then your xorg.conf lost some info. To fix your compiz window decorations (titlebars) with an nVidia graphics card, run
sudo nvidia-xconfig --add-argb-glx-visuals -d 24
, then restart X by pressing conrol+alt+backspace.