sudo dd if=/dev/cdrom of=Name_Of_ISOFile.iso
where /dev/cdrom id the name of your device. I.e. if the device is a SCSI cd rom change it to
sudo dd if=/dev/scd0 of=Name_Of_ISOFile.iso
Since dd is not specific to CDs, it will also create disk images of floppies, hard drives, zip drives, etc.
To make an ISO from files on your hard drive, create a directory which holds the files you want. Then use the mkisofs command.
mkisofs -o /tmp/MyISO.iso /tmp/DirToMakeIsoFrom/
This results in a file called MyISO.iso in folder /tmp which contains all the files and directories in /tmp/DirToMakeIsoFrom/.
To test that the ISO was created successfully all you need to do is mount it.
sudo mount -o loop -t iso9660 Name_Of_ISOFile.iso /mnt/test