eject Command ejects removable media such as a CD, DVD, floppy, or tape. You may name the device by its /dev or /mnt filename. The /dev and /mnt prefixes are optional for any items in the /dev and /mnt directories. If no device is named, it is assumed that “cdrom” should be ejected.
Syntax:
eject [options] [device]
If you encounter the below error while running the command eject:
eject: command not found
you may try installing the below package as per your choice of distribution:
Distribution | Command |
---|---|
Debian | apt-get install eject |
Ubuntu | apt-get install eject |
Alpine | apk add util-linux |
Arch Linux | pacman -S util-linux |
Kali Linux | apt-get install eject |
CentOS | yum install eject |
Fedora | dnf install util-linux |
OS X | brew install eject |
Raspbian | apt-get install eject |
eject Command Examples
1. Display the default device:
# eject -d
2. Eject the default device:
# eject
3. Eject a specific device (the default order is cd-rom, scsi, floppy and tape):
# eject /dev/cdrom
4. Toggle whether a device’s tray is open or closed:
# eject -T /dev/cdrom
5. Eject a cd drive:
# eject -r /dev/cdrom
6. Eject a floppy drive:
# eject -f /mnt/floppy
7. Eject a tape drive:
# eject -q /mnt/tape