if you changing permisions only for files, than first you need to know what means rules for permissions. you have 777 for example, where first number 7 is rule for owner of the file, seccond number 7 is permission for group of users that own that file, band third number 7 is for anyone, declares roules for anyone on this planet :D now when you know what that 3 number means, you need to know how to built that numbers. you have permissions writte, which has value of 4, than you have read permission, which has value of 2, and the last one is execute permission which has value of 1. so number 7 means permission to: writte, read and execute, than if you have number 5, that means writte and execute....
now, if you want roule for some file to be, owner to has all privilegies, group read and execute, and anyone to read and execute, you will have number of 733.
now when you understand how to combine that numbers, it is time to know commands for changing permissions and ownership:
chmod xxx /filelocation (filelocation is path of file that you changing permissions) (xxx is combination of numbers that declares permission, you need to find rule number by combining numbers as explained above)
if you want to change owner of that file, you need to writte:
chown userthatyouwantasowner /file (that means that owner of that file will be given user instead of userthatyouwantasowner)
the next thing, if you making permission changes for folders, it is same as files, but not at all. if you want to add some rule for some folder, but only that folder, than writte:
chmod xxx /folder (folder or folder path example /var/www )
and difference is, if you want to change permission for that folder, and all content inside of that folder (subfolders, and folder files), you need to writte:
chmod xxx /folder -R (-R stands for recursive=applying changes to entire content of folder)
for changing owner of folder, just replace chmod with chown in both cases, and thats all.
if you liked my answer please comment, and remember, if you are not using terminal as root user logged, then before any comand you need to writte sudo (to tell to computer that sudo(superuser do))!!!!!
hope this will help you!!!!