eject command in Linux with examples - GeeksforGeeks

15 May, 2019
eject allows ejecting a removable media (typically a CD-ROM, floppy disk, tape, or JAZ or ZIP disk) using the software. You can also control some multi-disc CD-ROM changers, the auto-eject feature (supported by some devices) and also close the disc tray of some CD-ROM drives. The methods of ejecting depend on the device type, whether it is a CD-ROM, SCSI device, removable floppy, or tape. The default action of eject is that it tries all four methods in order until it achieves success. The device is unmounted, if it is mounted, before ejecting.
Syntax:
eject [...OPTIONS]
Options of the eject command:
-h or –help : Display help for available commands.Syntax:eject -hOutput:
Syntax:
eject -h
Output:
-v or –verbose : Log out more information about the command’s execution.Syntax:eject -vOutput:
Syntax:
eject -v
Output:
-d or –default : List default device name.Syntax:eject -dOutput:
Syntax:
eject -d
Output:
-a on|1|off|0 or –auto on|1|off|0 : Control auto-eject mode supported by some devices with this command. Enable this to auto-eject when the device is closed.Syntax:eject -a on
Syntax:
eject -a on
-c or –changerslot : Select a CD slot from an ATAPI/IDE CD-ROM changer. You need Linux 2.0+ to use this feature. You have to make sure that the CD slot is not already in use. The first available slot is referred to as 0.Syntax:eject -c 0
Syntax:
eject -c 0
-t or –trayclose : Use this command to give the drive a tray close command.Note: Hardware support for this feature is limited.Syntax:eject -t
Note: Hardware support for this feature is limited.
Syntax:
eject -t
-T or –traytoggle : This option gives the tray close command, if the slot is open, or an eject command, if the slot is closed.Note: Hardware support for this command is limited, as it makes use of the above -t command.Syntax:eject -T
Note: Hardware support for this command is limited, as it makes use of the above -t command.
Syntax:
eject -T
-x or –cdspeed : Give a CD-ROM select speed command to the drive with this option. An argument is a number, which indicates the desired speed (e.g. 3 for 3X speed), or 0 for maximum data rate. Device support for this command is limited, and you can only specify speeds that the drive is capable of. The option is cleared everytime the media is changed. This option can also be used with -c or -t command.Syntax:eject -x 0
Syntax:
eject -x 0
-X or –listspeed : Display a list of available speeds from the CD-ROM drive using this option. You can use the speeds listed as an argument in the -x option. You need Linux 2.6.13+ to work with this option. On older versions, it will only report the maximum speed. Also, some drives may not correctly report the speed, thus this option does not work with them.Syntax:eject -X
Syntax:
eject -X
-n or –noop : Display the selected device, but perform no action using this option.Syntax:eject -nOutput:
Syntax:
eject -n
Output:
-r or –cdrom : Specify that the drive should be ejected using a CDROM eject command using this option.Syntax:eject -r
Syntax:
eject -r
-s or –scsi : Specify that the drive should be ejected using SCSI commands using this option.Syntax:eject -s
Syntax:
eject -s
-f or –floppy : Specify that the drive should be ejected using a removable floppy disk eject command using this option.Syntax:eject -f
Syntax:
eject -f
-q or –tape : Specify that the drive should be ejected using a tape drive offline command using this option.Syntax:eject -q
Syntax:
eject -q
-p or –proc : Use /proc/mounts instead /etc/mtab with this command. It also passes the -n option to umount.Syntax:eject -p
eject -p
-m or –no-unmount : Allow eject to work with device drivers which autonomously mount removable media and therefore must be always mounted. The option tells eject not to try to unmount the given device, even if it is mounted according to /proc/mounts or /etc/mtab.Syntax:eject -m
Syntax:
eject -m
-V or –version : Log the version number to console and exit.Syntax:eject -VOutput:
Syntax:
eject -V
Output:
Exit Status: On successful operation, 0 is returned, and on failed operation, 1 is returned.
linux-command
Linux-misc-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
scp command in Linux with Examples
nohup Command in Linux with Examples
mv command in Linux with examples
Thread functions in C/C++
Docker - COPY Instruction
chown command in Linux with Examples
nslookup command in Linux with Examples
SED command in Linux | Set 2
Named Pipe or FIFO with example C program
uniq Command in LINUX with examples