Home / Alt manpages / scrot(1)

  • scrot(1)
  • User command
  • linux

Take Screenshots from the Command Line with scrot

scrot captures the whole X display, a single focused window, or a mouse-dragged region, and writes it straight to a file you name yourself. The examples use scrot 1.10, installed here as Debian package 1.10-1build2. Allow about ten minutes if your X display is already working.

You need the scrot package, an active X display, and permission to write to the destination directory. These are ordinary user commands; skip sudo entirely, since elevated privileges will not fix a missing display or make a screenshot any safer.

1. Check the command and the display

Start with read-only checks. scrot is an X screenshot utility, so a text-only session, a remote connection without X forwarding, or a Wayland-only desktop may not give it a usable display at all:

$ command -v scrot
/usr/bin/scrot
$ scrot --version
scrot version 1.10
$ printf 'display: %s\n' "${DISPLAY:-not set}"
display: :0

Your display value can differ. What matters is that command -v finds the binary you expect, and DISPLAY is set to the X display you actually want to capture. To target another one, use -D or --display, for example scrot --display :1: do not guess a display number on a multi-user host.

2. Capture the full display with a timestamped name

With no selection option, scrot captures the display and saves an image. Give it a filename containing a strftime pattern so repeated captures never collide:

$ mkdir -p "$HOME/Pictures/screenshots"
$ scrot "$HOME/Pictures/screenshots/%Y-%m-%d_%H-%M-%S.png"
$ ls -lh "$HOME/Pictures/screenshots/"

scrot expands the filename when it runs. The .png suffix selects PNG, and the file lands under your home directory. A successful capture normally prints nothing at all; the listing should just show a new file such as 2026-09-26_14-30-00.png, though timestamp and size will differ for you.

Checkpoint

Verify the image type without opening it:

$ file "$HOME/Pictures/screenshots/2026-09-26_14-30-00.png"
/home/you/Pictures/screenshots/2026-09-26_14-30-00.png: PNG image data, ...

Swap in the timestamp that actually exists on your machine. The shell expands ~ in an unquoted word, but "$HOME" keeps the path clear when it sits next to other text.

3. Capture the focused window

Use --focused when the target window is already active:

$ scrot --focused "$HOME/Pictures/screenshots/focused-%Y-%m-%d_%H-%M-%S.png"
$ file "$HOME/Pictures/screenshots/focused-2026-09-26_14-31-00.png"
/home/you/Pictures/screenshots/focused-2026-09-26_14-31-00.png: PNG image data, ...

The window has to be focused at the exact instant scrot fires. Need to pick the window yourself instead? Use interactive selection. Window decorations are not automatic either: add --border when selecting a window and you also want the window manager's border included.

4. Select a window or rectangle

Run --select, then click a window or drag across a rectangle; arrow keys resize the selection:

$ scrot --select "$HOME/Pictures/screenshots/area-%Y-%m-%d_%H-%M-%S.png"

Selection is interactive, so keep the terminal available while you move the pointer, and press Escape to cancel. For a visible countdown before selection starts, combine --delay with --count:

$ scrot --count --delay 5 --select "$HOME/Pictures/screenshots/area-%Y-%m-%d_%H-%M-%S.png"
5
4
3
2
1

Need the delay to happen before you even start selecting? Prefix the seconds with b, as in --delay b5. Without that prefix, the delay applies after selection, right before the capture.

5. Stop an existing file being replaced

scrot refuses to overwrite the output file by default, which is a useful guard whenever you use a fixed filename:

$ scrot "$HOME/Pictures/screenshots/latest.png"
scrot reports that the destination exists and leaves the previous image in place.

The exact diagnostic text varies by packaging. Use --overwrite only when replacing that exact file is intentional:

$ scrot --overwrite "$HOME/Pictures/screenshots/latest.png"
$ file "$HOME/Pictures/screenshots/latest.png"
/home/you/Pictures/screenshots/latest.png: PNG image data, ...

Warning

This is a destructive action for the previous screenshot, and scrot has no undo. If the old image matters, copy it first, or just use a timestamped filename and leave the old file alone.

6. Use quality, format and metadata deliberately

The file extension normally selects the format, and --format makes that choice explicit. Quality runs 1 to 100 and defaults to 75, though its effect depends on the format:

$ scrot --format jpg --quality 90 "$HOME/Pictures/screenshots/review-%Y-%m-%d_%H-%M-%S.jpg"
$ file "$HOME/Pictures/screenshots/review-2026-09-26_14-35-00.jpg"
/home/you/Pictures/screenshots/review-2026-09-26_14-35-00.jpg: JPEG image data, ...
  • PNG is lossless, so quality is ignored. Keep PNG for text and interface screenshots where exact pixels matter.
  • JPEG quality affects the result, and compression is tied to it. scrot's default compression level is 7, which is not a reason to change quality for PNG. Choose JPEG when a smaller, lossy file is fine.
  • Add --pointer to include the mouse cursor.
  • Add --thumb 25 for a 25 percent thumbnail, or an explicit size such as --thumb 320x240. The thumbnail name reaches an execution command through the $m special string.

7. Add a safe post-capture action

--exec runs a command after the image is saved, with $f expanding to the saved file's full path. Quote the command as one shell argument, and never feed untrusted text into it:

$ scrot "$HOME/Pictures/screenshots/%Y-%m-%d_%H-%M-%S.png" \
    --exec 'file "$f"'
/home/you/Pictures/screenshots/2026-09-26_14-36-00.png: PNG image data, ...

It is handy for verification or a known local converter. It runs after capture, so a failure in the post-capture command does not mean the screenshot was never written. Treat --exec as shell execution: do not expand data from filenames, window titles or other untrusted sources into a new command built on the fly.

Common traps

If scrot cannot open the display, check DISPLAY, confirm the session is actually X11, and check that your user owns or can access that display. A file-exists report means choosing a new name or making the replacement explicit with --overwrite. If selection never appears, check the command started from the same graphical session, and that another window is not holding the pointer or keyboard grab.

For a fixed window identifier, get a valid X window ID from xwininfo first, then pass it to --window; do not paste a window title where an identifier belongs. Capturing another user's display or window can expose private material and may be blocked by the X server: only capture displays you are authorised to see.

Done means

  • scrot --version reports the installed version and the intended X display is set.
  • A full-display, focused-window or selected-area screenshot exists at the expected path.
  • file confirms the output format, and the destination was not silently overwritten.
  • Timestamped names cover repeatable captures, or --overwrite was chosen knowingly.
  • Any --exec command is quoted, local and safe to run against the saved image.