Solution:
For best practices refer to the wordpress codex. [1] It is not very wise to assign 777 permissions to your files.
I would usually cd to the directory containing wordpress installation i.e. where wp-content, wp-admin and wp-includes exist. Then run the following commands
To set permissions for directories
find . -type d -exec chmod 755 {} \;
To set permissions for files
find . -type f -exec chmod 644 {} \;
[1]. http://codex.wordpress.org/Hardening_WordPress#File_permissions