How to open text, video, or picture files via terminal

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:[email protected]

should open your default mail program's composer, with [email protected] in the To: field.

If what you want to view videos on a virtual terminal, without Xorg, you can use mplayer with the directfb, fbdev, fbdev2, sdl (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.


To open a video from terminal

  • First install vlc player by running the below commands on terminal

    sudo add-apt-repository ppa:videolan/stable-daily
    sudo apt-get update
    sudo apt-get install vlc
    
  • Then go into the directory which contains videos you want to play,

    cd /path/to/the/directory/which/contains/videos
    
  • Play the video from terminal using vlc player,

    vlc "videofilename.fileformat"
    

To open a picture from terminal,

  • Install shotwell to open a picture via terminal,

    sudo add-apt-repository ppa:yorba/ppa
    sudo apt-get update
    sudo apt-get install shotwell
    
  • Then go into the directory which contain picture you want to open,

    cd /path/to/the/directory/which/contains/picture
    
  • Open the picture via terminal using shotwell,

    shotwell "picturefilename.fileformat"