how to mount cd's and pendrives in linux?

First, which distro are you using? Ubuntu, and I think the most of them, automagically mount cd's and pen drives. If not, there's the mount comand.

mount -t iso9660 /dev/hdc /media/cdrom0/

thats an example of mounting a cd manually.

mount /dev/sda1 /mnt/usbflash

thats an example of mounting a flashdrive...

both examples could be silghtly different depending on your system and what kind of filesystem exist on the flashdrive.

mount /dev/sda1 /mnt/usbflash

Will work only if entry is there for /dev/sda1 in /etc/fstab . And generally, USB drive will be assigned /dev/sdb1
Better way will be to use

mkdir /media/flash
mount -t auto /dev/sdb1 /media/flash/

Now it will be shown on desktop as well as side panel in nautilus(If using gnome)

Most Linux distributions automatically detect thumb drive or any usb drive when you plugged it in the computer's usb port. It's the same for cd or dvd. You can check with 'cat /proc/scsi/scsi ' to see if thumb drive is detected.

To see what the thumb drive mount point is, issue this command:
dmesg | grep sd

For cd or dvd drive, replace 'sd' with 'hd' or 'cdrom'.

To mount a thumb drive:
mount -t vfat /dev/sdb1 /mnt/memory

Replace 'sdb1' with your usb or cdrom drive mount point and '/mnt/memory' to where ever you want to mount the drive.

If you are using Ubuntu desktop, no permission needed. That means you can use the device right away after it's been plugged in (of course after it's been detected) .

Reference:
How to mount and unmount usb drive or thumb drive in Linux

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.