Quick Tip: Eject Media from Command Line on Mac OS X

Mar 26, 2007 - 10 Comments

A disc

Ever needed to eject a disc, cd, DVD, or media from the command line on a Mac? You can do that from the Terminal, as we’ll show here.

To eject a disc or media from the command line on Mac, open up your Terminal and type the following:

drutil tray open

or you can type to eject directly if you do not have a tray-operated superdrive or disc reader

drutil eject

Both of those commands should work to eject whatever media is stubbornly staying in the drive (unless of course the drive is damaged).

If you’re feeling cheeky and wanted to play a prank on someone, using those commands you could ssh into their machine and eject whatever media is in their drive, but that would be mean. On a more serious note, using the command line does offer remote ejection of media, which can be very helpful.

Perhaps you’ve run into the following problem: some inserted media (either a CD or DVD disc) refuses to eject itself when you hit the eject key. Often a reboot will fix this problem, but before you try rebooting, try the command line trick above, it just may work as well.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS X, Tips & Tricks

10 Comments

» Comments RSS Feed

  1. […] vyjmutí média z mechaniky drutil eject nebo drutil tray open, když se mac rozhodne vám médium nevydat, tak před restartem zkuste terminál  […]

  2. Achey Breaky says:

    With the new eject delay from 10.4.9 this is actually very very useful to immediately spit out a disk, thanks for the tip

  3. popctrlx says:

    how can a i make this from windows xp/cmd screen

  4. prank says:

    >>>If you’re feeling cheeky and wanted to play a prank on someone, using those
    >>> commands you could ssh into their machine and eject whatever media is in their drive,
    >>>but that would be mean.

    nah.. put it into crontab :D

  5. kaikaikai says:

    tried this and everything else.
    still my dvd wont eject on my macbook pro :[

    • phillip says:

      Same problem here – can’t get the DVD out

    • Benji says:

      both of those commands should work to eject whatever media is stubbornly staying in the drive (unless of course the drive is damaged)

      May I point out the bit in brackets guys? Maybe try reading it again

      • John W says:

        My drive is in perfectly good shape and still no eject. Had to force reboot the machine and remove the disc on startup. These commands DO NOT work for EVERY disc.

  6. Elle Urquhart says:

    I found a brad awl did the trick :)

  7. alex says:

    Check for bent opening. My mbp had upper side of the opening bent which basically kept cds from coming out.

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates