Quick tip: Eject and Insert CD / DVD media under Linux

last updated in Categories Hardware, Linux, Linux desktop

Eject command allows removable media (typically a CD-ROM, floppy disk, tape, or JAZ or ZIP disk) to be ejected under software control. The command can also control some multi-disc CD-ROM changers, the auto-eject feature supported by some devices, and close the disc tray of some CD-ROM drives.


Eject using device name (DVD/CD)

eject /dev/dvd
eject cdrom
eject /mnt/dvd

Close tray:

eject -t /dev/dvd

Eject first SCSI device:

eject sda

Select CD slot

The command can also control some multi-disc CD-ROM changers (note that the first slot of the changer is referred to as 0, not 1):
eject -c 1 /dev/cdrom


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.