To do sam to bam conversion, follow the following commands :-
$ samtools view -b -S file.sam > file.bam
Then you will need to use
$ samtools sort file.bam file-sorted
followed by
$ samtools index file-sorted.bam
in order to get an indexed file.
If you just type
$ samtools
or samtools followed by the name of one of the samtools commands, you will get a few lines of help giving the correct syntax for that command,