Eject a disc or USB drive with the eject command
Safely open the DVD tray or mark a USB stick safe to remove without using a file manager.
01Command
$ eject /dev/sr0 && eject /media/$USER/USBDRIVE02What it does
eject first unmounts any filesystem on the device, then either opens the tray of an optical drive or signals the kernel that removable media can be pulled out. You can pass the device node (/dev/sr0) or an existing mount point. If the drive is busy, close programs using it and retry.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- eject(1) — eject removable mediaEvidence: eject unmounts the filesystem if mounted and opens the tray or marks the device safe to remove; it accepts device names like /dev/sr0 or mount points.
Last verified: 2026-09-18 · Category: Files & Folders
06Related solutions
autoremove deletes no-longer-needed dependency packages, and clean wipes the downloaded .deb cache in /var/cache/apt/archives.
ncdu scans a directory tree, then lets you browse sizes, navigate, and delete space hogs with one keypress.
Check how much space the binary journal consumes and permanently trim it by size, age, or file count.