Completely restore root and home folder after many problems with Macports and Homebrew I had a long day battling with installing a LAMP environment with Macports. I installed several things, had many problems, tried uninstalling them (not sure if I did), and on and on. Then, I tried doing the same thing in Homebrew. Same story. I then completely reinstalled Mavericks and did it all over again. 

The problem is that I don't know what files should be there and which shouldn't. (I'm pretty much a beginner with this). If I knew, I guess I wouldn't have to reinstall the OS again. How can I completely restore it to what it was before I even opened the Terminal?

Here is what I have in the root directory:



And in my user directory:



(I can upload more images or ls outputs if needed)
All those files look normal to me, including the hidden ones.  Unless you had/have an active backup from a date before your changes, there is no way to "restore" it back to an exact state before "opening Terminal". (That made me chuckle)  That being said...

Should be possible to back up user data (your home folder entirely), erase your hard drive (from the Recovery partition if necessary), reinstall OS X, and move your user data back.  The sacrifice there is any system-level applications/preferences that you've set.  However, it's likely the Homebrew/MacPorts settings on the system-level that are causing your issues.

It really boils down to how much time you want to spend digging through documentation, trying different things, changing different settings to get your system back to the way you want it.  If you have the time and patience, it will be much more rewarding and (possibly) less impactful to your OS X environment.

On the flip side, it's sometimes easier (and more time-effective) to just "nuke and pave" as we call it. :)