If you need to fix it that first check what the permissions should be. They might not all be root:root. Worst case they are not and you discover this a lot later after trying to figure out why something else does not work.
Install an identical version of Ubuntu somewhere. Check all permissions.
If they are all root:root then get a root prompt. Either by booting a liveCD or somehow boot into single user mode. (e.g. LILO with init=/bin/bash, or shift-GRUB). Mount the filesystem containing /etc and chown the files to the right permissions.
If not all files are root:root then you might want to construct a script to set the values (use the identical install you made earlier to look up what those values are).
If this is a nice fresh install you can try to copy a fresh etc from the other install (move the old /etc to another place, e.g. to mv it to etc.backup and copy a fresh one from a pendrive. If you do this you will need to make sure what password is set because you are also overwriting the password files)
However if this is a relative new install which you are still setting up: Just reinstall.
Quickest, safest, but least educative.
Permissions of this type are
discretionary access controls
. They're called discretionary because the operating system can use its discretion to decide whether it should respect them or not. It is possible to override DACs by mounting your drive in another system (or even booting a Linux Live CD), acquiring root through that system, and setting the permissions appropriately. – allquixotic – 2012-11-06T21:33:39.817