Mastering the Linux eject Command: Options, Syntax, and Practical Examples
Learn how to use the Linux eject command to safely remove removable media, including its syntax, available options, and step‑by‑step examples for ejecting CD‑ROMs, SCSI devices, floppy disks, and tape drives, even when they are mounted.
eject: Exit removable devices
Function description
The eject command is used to exit removable devices. If the device is mounted, eject will first unmount it before exiting.
eject allows removable media (typically CD‑ROM, floppy, tape, JAZ, or zip disks) to be ejected under software control. It can also control multi‑disc CD‑ROM controllers, devices that support automatic ejection, and the closing of CD‑ROM trays. The name argument can be a device file, a mount point, a full path, or omit the leading /dev or /mnt. If omitted, cdrom is used by default. Four different ejection methods exist, depending on whether the device is a CD‑ROM, SCSI device, floppy, or tape. The default method tries each in turn until successful. If the device is currently mounted, it will be unmounted first.
Command syntax
eject [options] [name]Option meanings
-h : Show help
-v : Verbose output
-r : Eject CD
-s : Use SCSI command to eject
-f : Eject floppy disk
-q : Eject tape
-p : Use /proc/mounts instead of /etc/mtab
-d : Show what would be done without executing
-a : Control automatic ejection
-c : Select drive in a multi‑drive enclosure
-t : Close the CD tray
-n : Show specified device
Parameter examples
(1) Eject the default device # eject (2) Eject a device or mount point named cdrom # eject cdrom (3) Eject the device /dev/cdrom # eject /dev/cdrom (4) Eject the device mounted at /media # eject /media (5) Eject the first SCSI device # eject sda (6) Eject the partition sda3
# eject sda3Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Linux
Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
