Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm running AWS EC2 Micro instance and had issues getting permission to the root access with EC2-user.

Followed a tutorial online and ran the following commands:

sudo chgrp ec2-user /etc
sudo chmod 660 /etc

Now it's telling me

-bash: /etc/profile: permission denied

How do I go back to the original setting?

share|improve this question

migrated from stackoverflow.com Apr 16 '13 at 11:50

This question came from our site for professional and enthusiast programmers.

1 Answer 1

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:

  1. Do not execute commands (especially as root/with sudo) if you do not know what the commands mean.
  2. 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.
share|improve this answer
    
Thank you so much. Very help full info, I've open the Java SSH Client and added the chmod +x /etc it gave me the following: Last login: Tue Apr 16 06:56:16 2013 from c323400222d11b3ea-cm00222332233e6.cpe.com.cable.rogers.ca -bash: /etc/profile: Permission denied [I have no name!] @ ~ ⯠chmod +x /etc chmod: changing permissions of `/etc': Operation not permitted [I have no name!] @ ~ ⯠–  GitRight Apr 16 '13 at 14:11
    
I have no name is probably because you can not read /etc/password (which is need to translate your ID to your username). Did you enter the commands as shown, or did you originally also use -r (recurvive, in other words also change each file in /etc). Can you add the output of ls -ld /etc. And maybe of a few files? –  Hennes Apr 16 '13 at 14:15
    
I'm a newbie at this, thanks for your patience. I used chmod 600 /etc but it said invalid mode. Is there a way to revert back? or what are the exact steps. –  GitRight Apr 16 '13 at 14:55
    
This case is similar to what I have. Not sure if their solution works somehow. superuser.com/questions/469120/… –  GitRight Apr 16 '13 at 15:34
    
1) Can you still log in as root? If not you will need to boot another OS (e.g. a liveCD) and mount the old root, then change permissions. 2) One way to force a working (but horrible) situation would be chmod -R +rx /etc. That would set every file and every subdir in /etc to readable and executable, probably resulting in a working system. However the preferred goal is to reset to the old permissions. For this you either need a reinsallation (easiest, esp on a EC2 instance), or another working machine to see what the permission should be. (and a lot of work or a script to set those permi. –  Hennes Apr 16 '13 at 15:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.