directory permissions

Asked by Matias Liopoldi

I create a new directory in my home with permissions "chmod 777"....i delete this folder and create a new folder with the same name and automatically this folder have permissions 775, is share and all the users in the network can used, like a regular share folder, without my authorization

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Rouben
Solved:
Last query:
Last reply:

This question was originally filed as bug #1223006.

Revision history for this message
Bryan Fullerton (fehwalker) said :
#1

Thank you for taking the time to make Ubuntu better. This sounds like a question around how permissions work, possibly specific to your system, so I'm moving it to be a question.

Revision history for this message
Matias Liopoldi (madaga22) said :
#2

You're welcome. I reported this because it look stranger to me.

Revision history for this message
Best Rouben (rouben) said :
#3

Hello Matias,

Default permissions on any folders and files you create are controlled by something called a "umask".

A umask is the opposite of a chmod. For example, if the umask is 0022, then your default permissions for new directory will be 777-022=755. For files, the default permissions are calculated like this: 666-022=644.

If you want to change the default permissions to be more restricted, you need to change the default umask. For example, if you set your umask to 0077, default permissions on everything you create will be very restricted, i.e. only the owner will have full access (7-0=7), while group and world will have no access.

tchakhma@rouben-amd64-desktop ~/test $ umask
0022
tchakhma@rouben-amd64-desktop ~/test $ touch testfile
tchakhma@rouben-amd64-desktop ~/test $ mkdir testdir
tchakhma@rouben-amd64-desktop ~/test $ ls -la
total 28
drwxr-xr-x 3 tchakhma staff 4096 Sep 27 01:43 .
drwx------ 44 tchakhma 1000 12288 Sep 27 01:43 ..
drwxr-xr-x 2 tchakhma staff 4096 Sep 27 01:43 testdir
-rw-r--r-- 1 tchakhma staff 0 Sep 27 01:43 testfile
tchakhma@rouben-amd64-desktop ~/test $ umask 0077
tchakhma@rouben-amd64-desktop ~/test $ touch testfile
tchakhma@rouben-amd64-desktop ~/test $ mkdir testdir
tchakhma@rouben-amd64-desktop ~/test $ ls -la
total 28
drwxr-xr-x 3 tchakhma staff 4096 Sep 27 01:44 .
drwx------ 44 tchakhma 1000 12288 Sep 27 01:43 ..
drwx------ 2 tchakhma staff 4096 Sep 27 01:44 testdir
-rw------- 1 tchakhma staff 0 Sep 27 01:44 testfile
tchakhma@rouben-amd64-desktop ~/test $

Reminder: the permissions are:
read=4
write=2
execute file or enter directory=1
Example1: 644 means owner=4+2(read+write),group=4(read),world=4(read).
More info: http://en.wikipedia.org/wiki/Filesystem_permissions#Numeric_notation

Revision history for this message
Matias Liopoldi (madaga22) said :
#4

Good answer!!!! Thanks!!!