Screenshot tools for the command line
Say Cheese
Linux is awash in desktop screenshot tools, but what if you want to take a quick screenshot from a terminal window?
Suppose you want to record the contents of a computer screen or window. Linux is blessed with a number of useful tools that capture the view on your screen at a given moment. You can use screenshots to preserve critical information, document the contents of web forms, or illustrate application procedures. Most of the popular screenshot tools, however, are desktop applications. What if you don't want to slow down and maneuver through a GUI just to capture the contents of your screen? Many users don't realize you can also create screenshots from the command line. Command-line screenshots are a quick and useful option when you are working in a terminal window, and conjuring up a screenshot through a one-line command means you can add screenshots to your Bash scripts. In this article, I'll show you three powerful screenshot utilities available in the Ubuntu 22.04 Linux command-line interface (CLI): scrot
, gnome-screenshot
, and import
.
scrot
SCReen shOT (scrot
) is a lightweight and simple command-line tool for capturing screenshots in Linux [1]. It offers a range of options and is highly configurable. To install scrot
on an Ubuntu 22.04 system (Figure 1), enter:
$ sudo apt install scrot
To capture a screenshot using scrot
, open a terminal and enter:
$ scrot myscreenshot.png
By default, scrot
captures the entire screen. However, you can also specify a specific window or region by providing additional arguments. For example, the command
$ scrot -s screenshot.png
captures a particular window or region you select using your mouse pointer. The -s
flag allows you to select the area to capture.
Above all, --quality
(-q)
is one of the features that fascinated me. You can use it to set the quality of the screenshot image on a scale of 1-100. For example, when I took a screenshot of a window with the quality set to 1
, I got an image size of 10.9KB (Figure 2). Whereas, when I set the quality to 100
, the file size becomes 1.0MB (Figure 3). This is particularly helpful when you have image size constraints for an application.
In addition, scrot
offers various additional options such as setting a delay before capturing, including the mouse in the capture, and using a different image format.
gnome-screenshot
On a Linux distribution with the Gnome desktop environment, gnome-screenshot
provides a feature-rich CLI for capturing screenshots [2]. To install gnome-screenshot
, use the regular apt
command (Figure 4):
$ sudo apt install gnome-screenshot
Basically, you can grab a screenshot using gnome-screenshot
by simply running the command (Figure 5):
$ gnome-screenshot -f screenshot.png
The -f
flag in Figure 5 sets the filename for the capture. By default, gnome-screenshot
captures the entire screen. Just like with scrot
, you can specify additional options to capture a specific region or window. For example, to capture a specific window, enter:
$ gnome-screenshot -w -d 3 -f screenshot.png
Here, the -w
flag sets the window to capture. With the -d
flag, you can insert a delay to the capture operation. There are also options for including the cursor in the screenshot and more.
Import
Part of the powerful ImageMagick suite, import
offers extensive capabilities for capturing screenshots from the command line [3]. ImageMagick is likely already installed on most Linux distros. If not, you can install it using the package manager specific to your distribution. For example, on Ubuntu 22.04, you can use:
$ sudo apt install imagemagick
To capture a screenshot of a specific window using import
, open a terminal and enter:
$ import screenshot.png
Next, import
asks you to select the target window using the mouse. It also allows capturing the entire X server screen using the id
or name
of the window:
$ import -window <window_id> screenshot.png
The <window_id>
attribute can be replaced with the actual identifier of the window you want to capture. Additional options provided by import
include delaying the capture, including the cursor, and output format customization.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.
-
Fedora 41 Released with New Features
If you're a Fedora fan or just looking for a Linux distribution to help you migrate from Windows, Fedora 41 might be just the ticket.