Eject/Close CD or DVD media with shell command

  • Tips
  • 1 min read

cuckoo clockShell command eject that is available by default in most of Linux distributions, allows to open and sometimes close removable media tray (usually it’s CD-ROM or DVD media).

To eject media:

eject /dev/cdrom


eject cdrom

As you see the name of device can be a device file or mount point, either a full path or with the leading “/dev”, “/media” or “/mnt” omitted. If no name is specified, the default name “cdrom” is used. With -c option a CD slot can be selected from an ATAPI/IDE CD-ROM changer.

To close tray:

eject -t cdrom

Dear reader, I hope you know what use eject command for if you came here, but let me suggest one more application. You can use this command to make your own cuckoo clock! 🙂

Just put little shell script opening and closing cdrom or dvd tray into cron…


16 thoughts on “Eject/Close CD or DVD media with shell command”

  1. Thank you. My desktop now has a pair of application links – "Open_DVD" and "Close_DVD". These replace what I was doing with "myComputer.desktop".

  2. The `eject -t` is a viable option for systems with electronically controlled media drives. Unfortnately, Dell 1950 and 2950 systems have simple physical/mechanical interlocks that work to eject the drive with the `eject` command, and/or pushing the drive open button. `-t` doesn't work to close the drives on such systems.


    -Joe Wulf, RHCT, VCP, USN(RET)

    Senior IA Engineer/ISSE

    ProSync Technology Group

  3. Saving $$$$$ money is key $25-$30 /m For ipads data package, not realizing when I bought the 16gb i Pad 3G I could have saved $100 buying the wyfi only. And I”m lucky to still have att&ts unlim plan. FREE tethering hell ya ; ) MYWI all the way!!!!iOS is real pain for me. Now, with 4.2 the speed is acceptable, but I still have problems with short baterry life. I am thinking about downgrade to iOS 3.1.3 again – using RectBoot utility. (My version history was 3.1.2 – 4.0 – 3.1.3 -4.2.0 – 4.2.1)No it doesn”t “spells” trouble for the other manufacturers. They are competing (mostly against each other) in a different space, at the low end. There will always be a larger market for cheap phones, even if those are now becoming cheap smartphones.

  4. 68. I have been absent for a while, but now I remember why I used to love this blog. Thanks , I’ll try and check back more often. How frequently you update your website?

  5. oakley replica sunglasses

    Bread and Butter by 2010 winter product exhibition opportunity and adidas homeopathic again this time the host

  6. Hello there. I discovered your blog by way of Google at the same time as looking for a similar matter, your web site came up. It appears great. I’ve bookmarked it in my google bookmarks to come back later.

  7. Credit Card Lawsuits

    Good – I should definitely say I’m impressed with your blog. I had no trouble navigating through all tabs as well as related info. It ended up being truly simple to access. Excellent job.

  8. Tower Defense Games

    Thank you for the sensible critique. Me and my cousin were just preparing to do a little research about this. We got a book from our local library but I think I learned more from this post. I am very glad to see such excellent information being shared freely out there.

  9. Hello. Very cool website!! Man .. Beautiful .. Amazing .. I’ll bookmark your site and take the feeds also…I’m glad to locate so much useful information here in the post. Thanks for sharing.

  10. Charlie Sheen is WINNING

    It continually is amazing to me how blog owners for example your self can find the time plus the dedication to carry on writing outstanding content. Your site isgood and one of my own need to read websites. I simply needed to say thanks.

  11. I actually wanted to write a quick message to appreciate you for all of the remarkable tricks you are writing here. My rather long internet look up has finally been paid with sensible facts to go over with my company. I ‘d claim that most of us site visitors actually are definitely blessed to live in a great community with so many perfect professionals with beneficial points. I feel quite privileged to have encountered your entire webpage and look forward to plenty of more awesome minutes reading here. Thanks a lot once again for all the details.

  12. Every few years, after a fresh install of an actual Distro, i come along and smile.

    Take the commands – put them to a hotkey/shortcut – forget them. XD
    Surely they can be found elsewhere…. But who cares???
    Right now its 13 years ago, that this was written!

    So, thanks for this!!!1

Leave a Reply

Your email address will not be published. Required fields are marked *