How to Eject a Cd/Dvd from the Command Line

I've just right clicked on the DVD icon in the Unity Launcher in order to eject it, but instead of hitting the 'Eject' button, I missed and hit the 'Unlock from Launchpad' option instead.

How do I go about ejecting the disk from the drive now that the Launcher option is missing?

6 Answers

In order to eject a disk from the drive, whether it's a CD or a DVD, open a terminal and simply execute the eject command.

5

To open the CD drive / eject the CD:

  • Open Terminal using Ctrl+Alt+T, and type eject
  • To close the tray, type eject -t
  • And to toggle (if open, close and if closed, open) type eject -T

All these commands can be typed into the run dialogue (Alt+F2)

For more options, type eject -h into Terminal.

Opening the Tray

Commands:

  • open tray: eject
  • close tray: eject -t

Easy Function for .bashrc

alias opentray='eject'

A few issues arise when ejecting drives. Sometimes they don't want to eject, because they are mounted etc. You can override this with eject -l /media/mountpoint or (/mnt/mountpoint). I wrote a function that can be called by simply typing opentray on your command line.

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.