解決在 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