Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Is it 444? Read all? – Ashfame Jun 27 '11 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 '11 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 '11 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 '11 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 '11 at 21:04
up vote 7 down vote accepted

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

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

Your Answer


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.