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 am getting to know linux little by little. I have just set up a new server and I see some behavior that I am not really used to. I have worked with servers before, that were not owned by me, and I have not seen this.

Basically, the folders that I create are automatically set to 775, and the files I create are set to 755.

On the servers I used to work with everything is set to 664 I think.

Now can I change this behavior, and more important, do I need to change this behavior. For now I am the only one using this server. The ports are all non-standard, and root logins are disabled.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Umask explained

The default file permissions on newly created files and directories are a standard permission (rw-rw-rw for files, rwxrwxrwx for directories) subtracting the current umask setting. A umask setting of 000 would keep the standard permissions, whereas a setting of 777 would remove all permissions.

The three numbers in the umask represent user, group and anyone permissions respectively. The number represents three binary digits whether to remove a specific permission or not.

d - rwx
-------
0 - 000 (rwx)
1 - 001 (rw-)
2 - 010 (r-x)
3 - 011 (r--)
4 - 100 (-wx)
5 - 101 (-w-)
6 - 110 (--x)
7 - 111 (---)

To calculate which permissions a new file will have given a certain umask, start with the default permission and subtract the umask.

orig    rwx rwx rwx (777, default directory permission)
umask   000 010 010 (022)
result  rwx r-x r-x (755)

orig   rw- rw- rw- (666, default file permission)
umask  000 010 010 (022)
result rw- r-- r-- (644)

orig   rwx rwx rwx (777, default directory permission)
umask  000 000 010 (002)
result rwx rwx r-x (775)

orig   rw- rw- rw- (666, default file permission)
umask  000 000 010 (002)
result rw- rw- r-- (664)
share|improve this answer
    
Thank you for clearing this up. –  Saif Bechan May 4 '12 at 19:48
add comment

That is defined by the "umask". You can have a look here for an explanation.

share|improve this answer
    
I will read into that, I think the solution is there. Do you think it is nessesary to have the change. or is the setup I have now just fine. It will be a production server tho. –  Saif Bechan Dec 7 '11 at 21:00
    
775 on directories is very loose, though not inherently insecure depending on where the files are located. The biggest issue there is that anyone will be able to see the contents of 775 directories, and the group owner has full access (could be good or bad). 664 is usually OK for files unless they're sensitive and you'd prefer other system users not be able to read them (if so assign 660 or 600). –  Garrett Dec 7 '11 at 21:54
    
775 (i.e. a umask of 002) is perfectly normal on a system with per-user groups. –  Richard Kettlewell Dec 8 '11 at 14:04
add comment

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.