You should be able to copy and paste all the following commands in. You can check the status of the commands after with
sudo ufw status
Allowing access to UniFi ports
sudo ufw allow 3478/UDP sudo ufw allow 5514/UDP sudo ufw allow 8080/TCP sudo ufw allow 8443/TCP sudo ufw allow 8880/TCP sudo ufw allow 8843/TCP sudo ufw allow 6789/TCP sudo ufw allow 27117/TCP sudo ufw allow 10001/UDP sudo ufw allow 1900/UDP
UniFI Video ports
sudo ufw allow 7080/TCP sudo ufw allow 7443/TCP sudo ufw allow 7445/TCP sudo ufw allow 7446/TCP sudo ufw allow 7447/TCP sudo ufw allow 10001/UDP sudo ufw allow 6666/TCP sudo ufw allow 7004/UDP sudo ufw allow 7442/TCP
Helpful links
https://help.ui.com/hc/en-us/articles/217875218-UniFi-Video-Ports-Used
https://help.ui.com/hc/en-us/articles/218506997-UniFi-Ports-Used