Open image artifacts from the CLI using a lightweight viewer or the system default opener. Validate file presence and choose the right approach for graphical versus headless environments.
You are working a ticket that includes screenshots and diagrams stored on disk. You need to confirm the files are present, open them from the shell, and avoid guesswork about which application should handle the file type.
Your approach depends on environment. On a headless server, GUI viewers are not useful; you either transfer the files off box or use a terminal-capable preview tool when available.
feh
).
viu
).
xdg-open
.
*.png
,
*.jpg
).
xdg-open
to hand off to the desktop’s configured default.
viu
can provide quick inspection when you cannot or do not want
to launch a GUI.
ls *.jpg
# OR
ls *.png
# OR
ls *.jpeg
This is the fastest “is it here?” check. If the glob matches nothing, your shell may print an error or return a non-zero status depending on settings.
# Expected pattern:
diagram.png
screenshot-01.jpg
sudo apt install feh -y
# OR
sudo dnf install feh -y
# OR
sudo pacman -S feh
feh
is a common lightweight viewer for X11 environments. If you
do not have a graphical session, this step will not be
useful.
# Expected pattern:
feh installs successfully (or reports already installed).
feh image.jpg
# OR
feh image.png
Use the explicit filename you identified in Step 1. This opens a window and renders the image in your GUI session.
# Expected pattern:
feh opens a window and displays the image.
sudo apt install viu -y
# OR
sudo pacman -S viu
# OR
cargo install viu
viu
renders images as ANSI and Unicode graphics in the terminal.
Output quality depends on your terminal and font support.
# Expected pattern:
viu installs successfully (or cargo compiles it).
viu image.jpg
# OR
viu image.png
If you are in a TTY or a limited terminal, you may get a poor result (or no useful output). In a modern terminal emulator, it typically renders well enough for a quick preview.
# Expected pattern:
a terminal-rendered preview of the image (quality varies by terminal).
xdg-open image.jpg
# OR
xdg-open image.png
xdg-open
delegates to whatever your desktop environment has set as
the default image viewer.
# Expected pattern:
the image opens in your default GUI application.
If you are on a headless host, GUI viewers like
feh
will fail. Transfer the file off box or use a terminal
preview tool when available.
xdg-open
relies on desktop integration and MIME associations. Verify
you are in a desktop session and that a default image viewer
is configured for the file type.
Tools like
viu
depend on terminal emulator capabilities and font rendering.
If output is unusable, use a GUI viewer or open the file on
another system.
Confirm you are in the expected directory and verify
filenames. If the extension differs, list with a broader
pattern or use
ls
on the directory to locate the asset.
This lab is read-only aside from installing packages. If you installed optional tooling for testing, remove it when you no longer need it.
# Debian/Ubuntu
sudo apt remove -y feh viu
# RHEL/Fedora
sudo dnf remove -y feh
# Arch
sudo pacman -Rns feh viu
ls *.png
: Lists files matching an image extension glob.
*.png
: Shell glob that matches files ending in
.png
.
feh <file>
: Opens an image in a lightweight GUI viewer.
viu <file>
: Renders an image as ANSI and Unicode graphics in the
terminal.
xdg-open <file>
: Opens a file with the system default application.