Creating a screenshot from the shell is useful when a desktop state needs to be documented in a ticket, attached to a report, or captured on a timer instead of with a keyboard shortcut.

On a current Ubuntu 24.04 GNOME desktop with the gnome-screenshot package installed, gnome-screenshot asks the active graphical session to save the full screen, the focused window, or a selected area directly to a PNG file. That keeps the flow short: run the capture command, wait for any delay to expire, and confirm that the image was written where expected.

These steps assume the shell is running inside the same logged-in graphical session that owns the desktop being captured. A text console, headless server, container, or plain SSH session without access to that display cannot capture the desktop surface, and --area still requires a mouse drag inside the graphical session.

Steps to create a screenshot with gnome-screenshot:

  1. Create or reuse a directory for the screenshot files.
    $ mkdir -p "$HOME/Pictures"
  2. Capture the current desktop to a PNG file.
    $ gnome-screenshot --delay=3 --file="$HOME/Pictures/desktop.png"

    --delay=3 leaves a short pause so a menu, dialog, or tooltip can be opened before capture. Successful runs normally print nothing, so the saved PNG file is the proof that the command worked.

  3. Confirm that the screenshot file was written as a PNG image.
    $ file "$HOME/Pictures/desktop.png"
    /home/user/Pictures/desktop.png: PNG image data, 1366 x 768, 8-bit/color RGB, non-interlaced

    file confirms that the path contains a real PNG image. The reported geometry changes with the current display resolution.

  4. Save only the currently focused window when the whole desktop is not needed.
    $ gnome-screenshot --window --file="$HOME/Pictures/window.png"

    --window captures the active window in the current graphical session instead of the entire desktop.

  5. Drag a rectangle when only part of the desktop should be saved.
    $ gnome-screenshot --area --file="$HOME/Pictures/selection.png"

    After the command starts, drag over the required area and release the mouse button to write the PNG file.