Take screenshots from the command line in Linux

By | November 28, 2010

There are many Linux applications dedicated to taking screenshots. However, you minght want to use the command line to do this, either because you want to build an automated script, or because you have a terminal screen handy.

import screenshot.jpg

This will allow you to select a rectangle using your mouse. The moment you let go of your left mouse button, a screenshot with the contents of that rectangle will be saved in the current directory.
And then there’s scrot.

scrot -d 4 screenshot.png

This will take a screenshot of your entire desktop, with a delay of 4 seconds between launching the command and saving the screenshot.png file. Use

scrot -c -d 4 screenshot.png

to also display a countdown in the console. Use

scrot -q 80 -c -d 4 screenshot.jpg

to save a JPG file with a quality of 80%.
You can also use special strings with scrot, as to produce filenames that contain the date and size of the screenshot:

scrot ‘%Y-%m-%d_$wx$h.png’ -e ‘mv $f ~/Desktop/Pictures/’

The command above will produce a file named 2010-11-28_2560x1024.png on my system and move that file to to a folder called Pictures, residing on my desktop.

4 thoughts on “Take screenshots from the command line in Linux

  1. ilde


    I use import quite a lot, in combination with OpenOffice.org, to prepare end user manuals for programs I build. However, as of today, I had no way to capture images of drop down boxes while displaying available options, as import is modeless. Now, with scrot, I can do it at last.

    Thanks for the tip!

  2. scribe63

    When you said “Take screenshots from the command line in Linux” is it safe to assume this can only be done in a GUI interface. Or, can it be done on a headless/TUI system also.


Leave a Reply

Your email address will not be published. Required fields are marked *