Xwd
xwd is an application that is standard among the X utilities, so it will come in any full X distribution.
xwd dumps the output of a window into a file that can be viewed with xwud, or converted with convert (part of ImageMagick package), xv or another tool to a more usable image type, like png.
There are also more convenient tools to make a Screenshot. You should use more reliable import (part of ImageMagick package) instead of xwd.
Examples
Next command will ask you to select a window (the cursor will become a + sign), then it will take a picture of the window (as it appears on the screen), the "-frame" options will have it also include the window managers decorative borders, then the file is converted to png
xwd -frame > out.xwd
To take a complete screen shot (no need to tell it what window to select):
xwd -root > out.xwd
Making screenshot and conversion at once:
xwd -frame | convert xwd:- out.png
Sometimes one need some delay in order to make some windows visible before taking screenshot:
sleep 4; xwd -root ...