11

I changed the permissions of my host file /etc/hosts by doing a chmod og+w.

What's the default permission so that I can switch it back?

5
  • Is it 444? Read all?
    – Ashfame
    Jun 27, 2011 at 20:41
  • The reverse of that command is sudo chmod og-w /etc/hosts. Most files have permissions like 644 and directories 755. Exceptions exists, highly sensitive files like /etc/shadow have 640.
    – Lekensteyn
    Jun 27, 2011 at 20:55
  • Thanks but I don't think the reverse applies for every command, may be just here but not in all situations and that's why I asked to be sure :)
    – Ashfame
    Jun 27, 2011 at 20:57
  • The sudo chmod o-w whatever can almost always be executed without pain. Only shared directories like /tmp or /var/tmp have that permission bit set, having it in other directories might introduce a security hole.
    – Lekensteyn
    Jun 27, 2011 at 21:00
  • Good point! I wasn't sure of the group part, may be it had the permission for the group and may be not.
    – Ashfame
    Jun 27, 2011 at 21:04

1 Answer 1

13

The default file permissions for /etc/hosts is 644. (readable and writable for the owner, root, and readable for others.)

3
  • Just curious, why it needs to be executable for the owner?
    – Ashfame
    Jun 27, 2011 at 20:53
  • 4
    It's not. 4 (read) + 2 (write) = 6. Read more on file permissions.
    – htorque
    Jun 27, 2011 at 20:54
  • oh sry, yes that makes sense.
    – Ashfame
    Jun 27, 2011 at 20:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .