open any file from terminal in linux

All window users know how to open a file with it’s default application, by simply double click on the file icon. Same can be done if linux is used in X Window Graphical User Interface. Eg. double click any .mp3 file to play the .mp3 in the default music player or double click any .pdf file in default pdf viewer. Now here we list how to open these files through (command line) terminal with their default applications.These commands work same as if you double click the file in GUI.

1. GNOME users – Use the following command with filename as the argument. It will open the specified file with the default application. There’s no need to remember the application command to run the file in that application.

gnome-open song.mp3

This will play the song.mp3 in the default music player.
or

gnome-open xyz.pdf

This will open xyz.pdf in default document viewer
or

gnome-open /

This will open the root directory in nautilus, the default file browser in X windows GUI.

2. KDE users – Use kde-open instead of gnome-open. Eg.

kde-open .

This will open the current directory in nautilus which is the default graphical file browser for most of the linux distros. And here “.” means the current directory.

3. Or you can use xdg-open same as gnome-open or kde-open. you can run the window-manager-neutral program called xdg-open. xdg-open is part of the xdg-utils package.

xdg-open abc.doc

This will use the default word processor of your system and open the abc.doc file with that.

Twit this with your twitter acount :

One thought on “open any file from terminal in linux

  1. Pingback: jesse

Leave a Reply