chmod is the change mode command, as indicated above.
The 777 indicates the permissions. there are three groups of people who can have permissions (each one gets their own digit), in order: Owner (of the file or directory, the first 7), group (everyone who belongs to the same group as the owner, second 7), and world (third 7).
Owner is the user of the file - that'd be you. In the *nix world, users belong to groups. So you might be user/owner Bob in group Marketing. This model lets you do things like say Bob can read/write the file, the rest of marketing can only read the file, and other users can read the file.
Each digit in the 777 is a binary representation of:
rwx (read/write/execute). So a chmod of 755 means:
111(7) - Owner can read write execute
101(5) - other in the group can execute or read, no write
101(5) - rest of world can read and execute, no write.
That setup means you can read/write and execute your files, but the people visiting your site can only read or execute the file. Thus you need to set programs in your cgi-bin to 755, so people can execute the file as a program.
If you set the permissions to 'chmod 644', you get a file that can be written by you, but can only be read by the rest of the world. This is good for straight HTML files so that no hanky panky goes on. But try and execute a file with permissions of 644 and you'll get an error.
The first 0 in the 0777 isn't normally used on websites, you can just worry about the last three digits.