How can I launch the GNOME image viewer from the terminal?

The command to use is eog (Eye of GNOME). And you call it like so:

eog filename

Use xdg-open:

xdg-open filename

which opens a file or URL in the user's preferred application.


Explanation

As long as you use Gnome and eog is your default image viewer, you can use gnome-open:

gnome-open filename

If you want an alternative that is independent of the desktop environment, use xdg-open which is bash wrapper around environment-specific commands.

For now, xdg-open supports:

  1. Xfce (exo-open "$1"),
  2. Gnome (gvfs-open "$1", gnome-open "$1" with fallback to generic open),
  3. KDE (kde-open "$1" with fallback to kfmclient exec "$1"),
  4. Mate (gvfs-open "$1", mate-open $1),
  5. LXDE (pcmanfm $1 with fallback to generic open),
  6. Enlightenment (enlightenment_open $1),
  7. Cinnamon (open_gnome3 $1, which is gvfs-open "$1" with fallback to generic open),
  8. Cygwin (cygstart "$1"),
  9. Darwin (open "$1").

and tries its luck with other desktop environments (called generics). $1 is your image filename.


Usage

xdg-open filename

If you want to figure out how xdg-open works, you can read bash source code:

$ locate xdg-open
/usr/bin/xdg-open
/usr/share/man/man1/xdg-open.1.gz
$ less /usr/bin/xdg-open

Edit

See also similar answer for different question on unix.stackexchange.com.


For Fedora you can use shotwell filename.

Tags:

Ubuntu

Gnome