How do I create a script file for terminal commands that require sudo permissions

I've written a bash script to help with this: https://github.com/waltinator/net-o-matic It watches the connection, and when the connection drops, does a user-specified thing to try to reconnect.

Look at the logs! sudo journalctl -b 0 -u NetworkManager. Read man journalctl.