Q . How to open text, video, or picture (any files) via terminal?

Brad Johnson. asked, Jan 25 ' 2017

I am new to ubuntu and I would like to know how to open a simple text file or open a video or a picture via the terminal

  • command
  • xdg-open

1 Answers

If you wish to open files in graphical applications from the command line, such as within gnome-terminal or xterm then simply run:

xdg-open $file

And it will open $file in an appropriate application for that file. The argument can also be a URL, so

xdg-open http://askubuntu.com/

will open this site in your browser, and:

xdg-open mailto:someone@somewhere.com

should open your default mail program's composer, with someone@somewhere.com in the To:field.

If what you want to view videos on a virtual terminal, without Xorg, you can use mplayer with the directfbfbdevfbdev2sdl (with the frame buffer back-end), or svga as the video output, by running

mplayer -vo fbdev2 file.mpg

For example. For still images, you can install the fbi package, and use it to display images on a framebuffer.

Leave a Ansewer