Image viewers on the computer, in smartphones or cameras can today read the orientation information in the EXIF data of an image and auto-rotate an image when displaying it to you. However, you might want some images to be actually stored in the orientation specified in their EXIF data. For example, this helps to render correctly in old or simpler image viewers that ignore the EXIF orientation information. EXIFTran is a tool that can help you achieve this.
$ sudo apt install exiftran
$ exiftran -a -i *.JPEG
Tried with: EXIFTran 2.10 and Ubuntu 16.04