The xwd program extracts visual information from a window, converts it into X Window Dump format, and prints the data to stdout. This output can be redirected to a file, and the file can be converted into GIF, PNG, or JPEG format, as shown in the previous recipe.
When xwd is invoked, it changes your cursor to a crosshair. When you move this crosshair to an X Window and click on it, the window is grabbed:
$ xwd >step1.xwd
ImageMagick's import command supports more options for taking screenshots:
To take a screenshot of the whole screen, use this:
$ import -window root screenshot.png
You can manually select a region and take a screenshot of it using this:
$ import screenshot.png
To take a screenshot of a specific window, use this:
$ import -window window_id screenshot.png
The xwininfo command will return a window ID. Run the command and click on the window you want. Then, pass this window_id value to the -window option of import.