import -window root filename.extension

where .extension == the graphics format to be used; any of the graphics formats supported in the imagemagick suite will work.. i.e. bmp, gif, png, etc.

NOTE: the import command is part of imagemagick, if you do not have imagemagick installed, you will need to do so in order to use import.

NOTE2: the Gimp also has a screen shot feature on the File menu under Acquire.