Clean MacOS system (clean terminal)
The simplest "whole system repair" is to reboot to Recovery  Cmd ⌘   R  at boot, then just reinstall the entire OS from there.

This will repair the OS, but not remove any data or apps.