Capturing screenshots on Linux helps document issues, preserve configuration states, and share exact visuals with teammates or support. When work happens primarily in terminals or over SSH, depending on desktop screenshot tools quickly becomes inconvenient or impossible.
On systems running an X11 session, common graphical utilities simply capture the contents of the root window or an individual application window. The ImageMagick toolkit includes the import command, which talks directly to the X server and saves images in formats such as PNG or JPEG, making it convenient to drive screenshots from a shell script or single terminal command.
Because import connects to the active display, a working graphical session and the correct DISPLAY and XAUTHORITY environment are required; capturing a pure virtual console (for example on tty1 without X) is not supported. On remote servers reached via SSH, either X11 forwarding or a virtual framebuffer such as Xvfb is necessary for screenshot support, and using timestamped filenames helps avoid overwriting previous captures and keeps images organized.
$ sudo apt update Hit:1 http://ports.ubuntu.com/ubuntu-ports noble InRelease Hit:2 http://ports.ubuntu.com/ubuntu-ports noble-updates InRelease Hit:3 http://ports.ubuntu.com/ubuntu-ports noble-backports InRelease Hit:4 http://ports.ubuntu.com/ubuntu-ports noble-security InRelease Reading package lists... Building dependency tree... Reading state information... 5 packages can be upgraded. Run 'apt list --upgradable' to see them. $ sudo apt install --assume-yes imagemagick xvfb x11-xserver-utils Reading package lists... Building dependency tree... Reading state information... imagemagick is already the newest version (8:6.9.12.98+dfsg1-5.2build2). xvfb is already the newest version (2:21.1.12-1ubuntu1.5). x11-xserver-utils is already the newest version (7.7+10build2). 0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
This command uses apt on Ubuntu and Debian systems; use the equivalent package manager command on other distributions, such as dnf on RHEL-based systems or zypper on openSUSE.
$ xvfb-run -a bash -c 'xsetroot -solid #263238; import -window root -pause 1 /root/sg-work/Screenshot-virtual.png'
Capture options:
More options for import:
$ import -help | head -n 4 Version: ImageMagick 6.9.12-98 Q16 aarch64 18038 https://legacy.imagemagick.org Copyright: (C) 1999 ImageMagick Studio LLC License: https://imagemagick.org/script/license.php Features: Cipher DPC Modules OpenMP(4.5)
$ file /root/sg-work/Screenshot-virtual.png /root/sg-work/Screenshot-virtual.png: PNG image data, 1280 x 1024, 1-bit grayscale, non-interlaced