Accidentally changed owner of /var system folder recursively to myself Long story short, accidentally I ran

sudo chown -R myusername /var/


and now my mac won't boot anymore (after entering user password for hdd decryption loading bar is slowly filled and after it gets full, nothing happens). I have access to the hdd via the OS X restore utilities (Cmd+R) on startup and managed to mount my hdd using terminal. What should I do to fix this? Should I sudo chown -R root /var/ now?

I also tried fixing the disk using Disk Utilities First aid, but that didnt work.
Since the system isn't bootable (in the normal sense), one easy way forward is to boot to Recovery HD and re-install the OS. There are thousands of files in /private/var that should be owned by root:wheel, _softwareupdate:_softwareupdate, myusername:staff, and hundreds root:admin so carpet bombing one ownership across the directories might lead to even worse breakage.

A reinstallation won't delete anything in the user and application folders but it also may or may not work - depending on if it moves aside /private and makes a new one or if it runs the equivalent of sudo /usr/libexec/repair_packages --repair --standard-pkgs --volume / which is a way to "repair permissions" on El Capitan if you managed to get things running again. If you have a recent backup, you could always just erase and reinstall from that.

I would try this as a first step to see if your system is salvageable. The repair_packages tool will run in single user mode, so that might be a nice thing to try after mounting / as read write (the syntax is provided when you boot). That tool used to be something you could run from Disk Utility, but now it's a command line tool for more specialized use apparently.