2

I recently found a question on superuser regarding ejecting a CD using the Windows command line.

How can I do this using Linux terminal?

TellMeWhy
  • 17,124
  • 39
  • 95
  • 141
  • Tried [`eject`](http://manpages.ubuntu.com/eject.1)? – muru Sep 14 '15 at 17:13
  • @muru wouldn't I need to specify exactly what I want to eject, in order to prevent the system from ejecting every external device? – TellMeWhy Sep 14 '15 at 17:14
  • Of course. What of it? – muru Sep 14 '15 at 17:14
  • @muru so, how would I do so? – TellMeWhy Sep 14 '15 at 17:15
  • If you could take a few minutes to read the manpage I linked to, you'd see: " The device corresponding to is ejected. The name 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." – muru Sep 14 '15 at 17:15
  • @muru ahh ok, I didn't realise it was a link... :) – TellMeWhy Sep 14 '15 at 17:16
  • 1
    and then after you eject it (if it can pull itself back in) you can use `eject -t`... – Gophyr Sep 14 '15 at 17:17

1 Answers1

5

The eject command does what you want. Without any arguments provided, it ejects the default (first) 'cdrom' device. If you want to eject a specific device, provide it as an argument.

eject /dev/cdrom1

Quoting from the eject manpage (man eject):

Eject 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.
The device corresponding to is ejected. The name 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.

gertvdijk
  • 67,007
  • 33
  • 188
  • 283