解决在 Ubuntu Bash 中 Couldn't get a file descriptor referring to the console

Yahya Irmak 2022年5月11日 Bash Bash Error
解决在 Ubuntu Bash 中 Couldn't get a file descriptor referring to the console

我们可以使用命令行在 Linux 中打开文件。但是,请根据你打开的文件类型使用合适的命令。

本文将解释如何解决在 Ubuntu 中使用 open 命令时出现 Couldn't get a file descriptor referring to the console 错误。

解决 Ubuntu Bash 中的 Couldn't get a file descriptor referring to the console 错误

Ubuntu 上的 open 命令执行的功能与 MAC 上的 open 命令不同。它是 openvt 命令的别名并打开虚拟终端,而不是文件。

如果你尝试使用此命令打开文件,你将收到 Couldn't get a file descriptor referring to the console 错误。你应该在 Ubuntu 中使用 xdg-open 命令正确打开文件。

xdg-open 命令在默认应用程序中打开文件或 URL。如果提供了 URL,则 URL 将在默认 Web 浏览器中打开。

如果提供了文件,则该文件将在该类型文件的默认应用程序中打开。

xdg-open filename

除了这个命令,你还可以对不同的文件类型使用不同的命令。

例如,nano 是终端的文本编辑器应用程序。使用以下命令打开文本文件。

nano file.txt

Shotwell 是为 GNOME 桌面环境设计的数码照片管理器。它支持 JPEGPNGTIFFBMPGIFWebPRAW 照片文件和视频文件。

你可以使用以下命令打开图像和视频文件。

shotwell image.png

EvinceGNOME 桌面环境的文档查看器应用程序。它支持 PDFPostscriptdjvutiffdviXPS 和许多其他文档格式。

你可以使用以下命令打开 pdf 文件。

evince file.pdf

你还可以通过选择适当的应用程序在 Linux Bash 中打开所有其他不同类型的文件。

Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe
作者: Yahya Irmak
Yahya Irmak avatar Yahya Irmak avatar

Yahya Irmak has experience in full stack technologies such as Java, Spring Boot, JavaScript, CSS, HTML.

LinkedIn

相关文章 - Bash Error