This can be achieved with ImageMagick or scrot. Install by running the command:
sudo apt-get install imagemagick
To grab all desktop just type:
import -window root screen.png
Or you can do it with a delay of 5 seconds
sleep 5; import -window root screen.png
#Using scrot