While looking if someone asked this question before, I landed on this for Windows.
I'd like to do something similar (shortcut or terminal alias/command) on Linux/Ubuntu to be able to quickly switch the external monitor between landscape and portrait mode instead of having to go to Displays setting it and confirming the configuration.
Jacob Vlijm provided a Python script which works. If you have another idea I'd love to know about it.
Update: I have updated Jacob's script to work for two screens if they are connected.