First, make sure you have ImageMagick installed:
#Ubuntu/Debian
sudo apt-get install imagemagick
#RedHat, Fedora, CentOS
sudo yum install imagemagick
After that, it's super easy.
mogrify -resize 800 -rotate 90 image.jpg
The above command would resize image.jpg to 800 pixels wide maintaining aspect ratio and rotate the image 90 degrees clockwise.
To define your own dimensions (discarding aspect ratio) use the following: