Take Screenshot from Command Line

To take a screenshot from command line (even from ssh connection) in a system running X server:

xwd -out screenshot.xwd -root -display :0.0

More about xwd here.

More options here.