There are times when it makes sense to rotate the photo, based on the extra information stored in the photo. The EXIF data contains this.
To download the tool on a deb distro:
sudo apt install exiftran
Once installed, you can rotate one photo with:
exiftran -ai
Or to all files in a directory:
for file in * ; do echo "$file" ; xiftran -ai "$file" ; done
Category: Linux