Skip to content
Tags

The umask…erm no this is not related to the film “The Mask” with the main actor being Jim Carrey!

December 31, 2010

Right, onto the ‘umask‘ command.

The ‘umask‘ actually sets the default permissions for all files and folders when they are created first.

You can check out what your ‘umask‘ level is by typing ‘umask‘ at the prompt and hitting return, this will give you the octal notational output: –

prompt> umask

0022 ### This is the octal notational value of the currentumask

To get the symbolic notation you must type ‘umask -S‘ and then hit return, this will show you the user, group and others read/write/execute permissions for the files & directories: –

prompt>umask -S

u=rwx, g=rx, o=rx

So as you can see above my ‘umask‘ value is set to 0022. If I subtract this from the initial permissions of 666 then this will give me my current permission values on all files that are created: –

666 ### Initial Permissions on each file that is created

-022 ### My currentumask‘ value

644 ### This shows that my current default permissions for any files that are created are at 644

The above calculation shows that every file that gets created will have the following permissions: –

User (owner) = Read & Write = 6

Group = Read Only = 4

Others = Read Only = 4

The above permissions have been worked out by using the following set of permission values for octal notations: –

4 = Read (r)

2 = Write (w)

1 = Execute (x)

Similarly we can find out what our current permissions for creating folders are by subtracting our current ‘umask‘ value by the initial permission for all folders which is 777: –

777

-022

755

Which means that the current ‘umask‘ will set the following permissions for the creation of folders : –

User (Owner) = Read, Write & Execute = 7

Group = Read & Execute = 5

Others = Read & Execute = 5

If you want to change the value of the ‘umask‘ and hence change the permissions set for new files and folders then you need to work out what permissions you want to set by using octal notation and then run the command ‘umask‘ with the argument being the octal notation you would like to set.

E.g. If I want to set the ‘umask‘ value to allow everyone to read, write and execute all new files and folders that are created then I will need to set the ‘umask‘ to 000: –

umask‘ for files to enable everyone to read (r), write (w) and execute (x) all new files

666

-000 ### By using this ‘umask‘ value will enable us to get 666 octal notational value permissions

666

umask‘ for folders to enable everyone to read (r), write (w) and execute (x) all new folders

777

-000 ### By using this ‘umask‘ value will enable us to get 777 octal notational value permissions

777

prompt> umask 0000 ### Setting theumaskvalue to the octal notation for r, w & x

prompt> umask ### Checking theumask value has saved the changes

0000 ### Currentumaskvalue has indeed been changed!

prompt> umask -S

u=rwx,g=rwx,o=rwx ### Shows the symbolic notation of the current ‘umask‘ set

And that’s that, that is what the current ‘umask‘ value is and how you change it. It will take a bit of time to get used to using this ‘umask‘ to set the correct permissions for the creation of files and folders but the more you do it the easier it will get!

Advertisements

From → Linux

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: