Clean MacOS system (clean terminal) I hope everyone is safe.

I tried to install an Apache version using brew yesterday on my MacOS Catalina, but there were conflicts with the Apache version of the system. After some tries, I deleted files I shouldn't have deleted. Is there a way to reset or reinstall or clean the Terminal, the binaries, and the system to have the factory settings? I already searched a lot but nothing worked for me.

Thanks by advance.
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.