Rotate an image automatically on Linux

sudo apt-get install jhead

jhead -autorot IMG_0428.JPG

jhead can also be used to read the exif info of a image.