Code:
samtools view -bF 4 file.bam > mapped.bam
will make a new .bam that has only mapped reads.
the -F 4 means that it will exclude entries in your .bam that have the 4 flagged in the binary flag; 4 is the code for unmapped read. The -b means that it will output a .bam, instead of a .sam, which is the default behavior for samtools view.