~$ apt-get source package
package is the software in question. You don't need
sudoin front of the command unless you're currently in a folder you're not supposed to have access to. The command proceeds to download at least 2 files; a .dsc file which is used to verify the downloaded package source, and the tarball (.tar.gz, .tar.bz2) which is the actual source itself. Optionally, there may be a .diff.gz file to accompany the downloaded source code.
apt-get does the verify & unpacking for you so there's no need to wonder how to proceed with unpacking things.
Just be sure to read the LICENSE file that comes with the package, and don't bother to try this on proprietary stuff. There's not gonna be source code for those (for obvious reasons ;) )