Shell 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
or
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…
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".
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.
R,
-Joe Wulf, RHCT, VCP, USN(RET)
Senior IA Engineer/ISSE
ProSync Technology Group
Application can’t eject but your suggestion does – It works.
Thank you.
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