You need to refer to your hosting provider documentation regarding proper permissions as they differ between different companies' set up. A thing that's certain is that setting a folder's permission level to 777 is an insecure way to handle privileges - this means that every user on the system would have access to it.
Within most companies' set up you should have directories to 755 and files to 644
And if you are managing your own server you should't be asking this question at all.
You may refer to the Ubuntu's file permissions documentation page regarding what each column digit means: https://help.ubuntu.com/community/FilePermissions
Permissions are set within the following order:
(u)(g)(o)
owner, group, other (respectively)
Overall the group and other columns should be paid most attention to, as setting them to 7 means that the folder/file would be globally readable and writable by a user belonging to any group or by any user on the system. On a shared hosting configuration this means that any user would be able to edit the other user's data where permissions are set to 777.