如何通过终端打开文本、视频或图片文件

Brn*_*rno 43 command-line

我是 ubuntu 的新手,我想知道如何通过终端打开简单的文本文件或打开视频或图片

dob*_*bey 61

如果您希望从命令行打开图形应用程序中的文件,例如在里面gnome-terminalxterm只需运行:

xdg-open $file
Run Code Online (Sandbox Code Playgroud)

它将$file在该文件的适当应用程序中打开。参数也可以是一个 URL,所以

xdg-open http://askubuntu.com/
Run Code Online (Sandbox Code Playgroud)

将在您的浏览器中打开此站点,并且:

xdg-open mailto:someone@somewhere.com
Run Code Online (Sandbox Code Playgroud)

应该someone@somewhere.comTo:字段中打开默认邮件程序的作曲家。

如果你想查看一个虚拟终端上的视频,没有什么的Xorg,你可以使用mplayerdirectfbfbdevfbdev2sdl(与帧缓存后端),或svga作为视频输出,通过运行

mplayer -vo fbdev2 file.mpg
Run Code Online (Sandbox Code Playgroud)

例如。对于静止图像,您可以安装该fbi软件包,并使用它在帧缓冲区上显示图像。


Tho*_*ard 2

要打开文本文件,您可以使用:

nano /path/to/file
Run Code Online (Sandbox Code Playgroud)

其中/path/to/file是文件在计算机上的存储位置,末尾是文件的实际名称。

因此,如果您将文件下载到Downloads目录中,并且您的用户名是example,文件名为test.txt,那么您可以执行以下操作:

nano /home/example/Downloads/text.txt
Run Code Online (Sandbox Code Playgroud)