@user7963's answer to use exiftran is right, but how do we use it? Here's what I found:
Tested on Ubuntu 20.04:
Install it:
sudo apt update
sudo apt install exiftran
Use it:
Convert all *.jpg images in dir_of_images to be automatically rotated in place according to their exif orientation metadata:
cd path/to/dir_of_images
exiftran -ai *.jpg
That's it! All *.jpg images will now have been rotated in place!
See man exiftran or exiftran -h for help and details.
Here are what the two options I used (-a and -i) mean:
TRANSFORM OPTIONS
-a Automatic (using exif orientation tag).
OTHER OPTIONS
-i Enable in-place editing of the images. Exiftran allows
multiple input files then. You must specify either this
option or a output file with -o for all operations which
modify the image (i.e. everything but -d right now).