On Unix-like operating systems, the eject command allows removable media (typically an optical disc) 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.

This page describes the GNU/Linux version of eject.

Description

When the eject command is executed, the device corresponding to is ejected. The name is 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.

  • Description
  • Syntax
  • Examples
  • Related commands
  • Linux commands help

There are four different methods of ejecting, depending on whether the device is a CD-ROM, SCSI device, removable floppy, or tape. By default, eject tries all four methods in order until it succeeds.

If the device is currently mounted, it is unmounted before ejecting.

Syntax

eject -h

eject [-vnrsfmqp] []

eject [-vn] -d

eject [-vn] -a on|off|1|0 []

eject [-vn] -c slot []

eject [-vn] -i on|off|1|0 []

eject [-vn] -t []

eject [-vn] -T []

eject [-vn] -x []

eject [-vn] -X []

eject -V

Options

Examples

eject

Eject the default device.

eject cdrom

Eject a device or mount point named cdrom.

eject /dev/cdrom

Same as above, but using the device name.

eject /mnt/cdrom/

Same as above, using the mount point.

eject hdd

Eject 4th IDE device.

eject sda

Eject first SCSI device.

eject sda4

Eject using SCSI partition name.

eject -v -c4 /dev/cdrom

Eject 5th disc on multi-disc changer.

mount — Mount a file system so that its data may be accessed.umount — Unmount a file system, making its data inaccessible.