First lets see what your command actually did, so you know what to undo:
sudo chgrp ec2-user /etc
As root, change the group for the directory /etc/ to ec2-user.
sudo chmod 660 /etc
As root, change permissions for /etc/ to 660.
On other words: set the permissions to rw- rw- ---.
What do these bits mean?
- Having access to
r for a directory means permission to get a list of file names within a directory. They do not affect access to files in the directory.
- Having access to
w for a directory means permission for:
- Creation of new files in the directory
- Removal of files in the directory. (delete, rm)
- Renaming of files into or out of the directory
- Linking of files into the directory (ln)
- Renaming a directory to a name in a different directory from where it started
- The 'x' bits affect looking up names in a directory (for instance, to open them) and also "cd" to the directory. To access files within a directory you need 'x' permission on it, plus whatever permissions on the files themselves are relevant to the operation you wanted.
On your system nobody at all has 'x' rights on /etc/.
No files can be looked up and opened. This include /etc/profile which is read (or rather, tried to be read) when you start a login shell. To fix this set the x permission back on /etc. E.g. chmod +x /etc which will allow x for all three in ugo. (User, groups, other)
Some hints:
- Do not execute commands (especially as root/with sudo) if you do not know what the commands mean.
- chown,chgrp and chmod (change owner, change group, change rights) all allow you to use both numbers (an octal representation) or the human friendly forms. E.g.
chmod u+r file to set the r bit for a user. This is much easier to learn.