It is just as much heavier to restore all permissions to the file system to the out-of-the-box install state, that it is more secure and faster to reformat partitions and reinstall the system than trying to undo a
sudo chmod -R 777 /
command. A system with 777 (rwxrwxrwx) permissions is just hopelessly broken. Any malware that attacks a security hole allowing execution of arbitrary code via browser can modify root-owned scripts and executables, while setuid's like sudo won't work if they are checking executable's permissions ...
In other words, on a system with world-writable 777 permissions browser cache is treated the same way the kernel image is. Simply nonsense.
In fact, sudo is checking its own permissions and they should be 4755
(rwsr-xr-x), but your friend had reset permissions to 0777 (rwxrwxrwx), which prevents sudo from running as it runs some security checks prior to starting your designated command.
But, anyway, sudo is pointless as you have already given world-executable permissions to any program on the computer, including possible malware in browser cache!
Format and reinstall is the safest way as your entire drive should be quarantined.