I have very specific questions regarding permissions. I have delved into the FilePermissions Wiki - <https://help.ubuntu.com/community/FilePermissions>
Recently I installed an ecommerce open source software on my LAMP server. It needed some permissions to be given.These were the two lines I executed ,blindly, in the terminal for all the permissions it needed- 

```
sudo chown www-data:www-data * -R
sudo usermod -a -G www-data $username

```

Please explain what these two lines of code did. The MAIN REASON I am posting this question is because *now* it has **locked some of my folders** How do I **revert all those permissions back to normal**? How would I know which folders' permission it has changed and what were their normal permissions? What is the difference between `chmod` and `chown` and which should be used here?