Eject Command
Eject Removable Media
The eject command in Linux and Unix-like systems is a
utility used to safely remove or eject removable media from a
device. This includes devices such as CD-ROM drives, floppy disk
drives, tape drives, and even USB drives or SD cards, depending on
system configuration and hardware support. Proper use of the
eject command ensures that data is not lost or
corrupted during the removal process, as it signals to the operating
system that the device is no longer in use and can be safely
detached.
Basic Eject Usage
The simplest form of the command, eject, will attempt
to eject any available removable media. This is often sufficient for
common devices like CD/DVD drives.
# Eject any available device
# CD-ROM, floppy disk, tape, or JAZ or ZIP disk
eject
Ejecting a Specific Device
You can specify the device you wish to eject by providing its path
as an argument to the eject command. This is useful
when you have multiple removable devices connected.
# Eject a device by its name
eject /dev/cdrom
Controlling Device Trays
The eject command also provides options to control the
physical tray of optical drives. The -t option is used
to close the tray.
# Close the tray using eject command
eject -t
Managing Hardware Eject Buttons
For devices with physical eject buttons, the
eject command can be used to enable or disable their
functionality. This can prevent accidental ejections.
# Lock the hardware eject button
eject -i on
# Unlock the hardware eject button
eject -i off