如何从命令行弹出CD / DVD
我刚刚右键单击Unity Launcher中的DVD图标以弹出它,但是我没有点击“弹出”按钮,而是点击了“从启动板解锁”选项。
现在,如果缺少Launcher选项,如何从驱动器中弹出磁盘?
要从驱动器弹出磁盘,无论是CD还是DVD,请打开终端并执行eject
命令。
要打开CD驱动器/弹出CD:打开终端ctrl + alt + t
,然后键入eject
要关闭托盘,请键入eject -t
并切换(如果打开,关闭,如果关闭,打开)类型eject -T
所有这些命令都可以输入到运行对话框中( alt + F2
)
有关更多选项,请在终端中键入eject -h
。
打开托盘
命令:
- 打开托盘:
eject
- 关闭托盘:
eject -t
.bashrc的简易function
alias opentray='eject'
弹出驱动器时会出现一些问题。 有时他们不想弹出,因为它们已安装等。您可以使用eject -l /media/mountpoint
或( /mnt/mountpoint
)覆盖它。 我写了一个函数,只需在命令行输入opentray
就可以调用它。
注意
这只适用于
- 你为你的驱动器
/dev/sr0
设置一个永久挂载点(与/dev/cdrom
,它只是象征性地链接到/dev/sr0
) - 将磁盘插入驱动器时会自动创建挂载点 。 (如果删除/注释掉rm -r“$ {mountdir}”存在的所有行,这样就可以忽略这一点,这样就不会自动删除挂载点)
- 必须以root身份运行,除非您手动更改了安装function的权限(我从未尝试过这个)
function opentray () { mountdir="/media/DVD" if [ -d "${mountdir}" ] # If directory ${mountdir} exists then if [ $(mount | grep -c "${mountdir}") = 1 ] # If drive is mounted, then then echo "/dev/sr0 is now mounted to ${mountdir}. I'll try to unmount it first and eject/open the tray." umount -l "${mountdir}" rm -r "${mountdir}" sysctl -w dev.cdrom.autoclose=0 # Ensure drive doesn't auto pull tray back in. eject exit else echo "/dev/sr0 is not mounted. Opening the tray should be easy. Ejecting/opening now." rm -r "${mountdir}" sysctl -w dev.cdrom.autoclose=0 # Ensure drive doesn't auto pull tray back in. eject exit fi else echo 'The directory "${mountdir}" does not exist. Ejecting/opening the tray.' sysctl -w dev.cdrom.autoclose=0 # Ensure drive doesn't auto pull tray back in. eject exit fi }
关闭托盘
为完整.bash_aliases
,您可以将此别名添加到.bashrc
(或.bash_aliases
文件)中,以从命令行将托盘拉回。 你不需要是root用户。
alias closetray='eject -t'