Link to home
Start Free TrialLog in
Avatar of dissolved
dissolved

asked on

umask?

When would you use umask?  Cant you just use chmod instead?  I know umask is used to set default permissions, but I do not understand when/how it would be used. Can anyone shed some light?
Thanks
SOLUTION
Avatar of kusuma_hs
kusuma_hs

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dissolved
dissolved

ASKER

ah, I see. Umask is defined globally in your unix box?  It is a value, that you subtract from the default file's permissions. ie: 777-444=333 (write ane execute permissions)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I just checked my box, my umask is set to 022. So this means when I create new files, they will have a default permission of what?
thanks!
depends on what permissions you give when you create the file. From the permission bits that you supply, the umask is deducted.
for eg, if you touch a file (which gives, I believe 666 file prmissions), the actual permissions that the file gets is 644. ie -rw-r--r--
what are default permissions?

Say I do a cat > test.txt
garbage here
CTRL Z

ls -l is showing  rw - r  -r  , which means default permissions were probably 666 (since my umask is 022). Am I correct?
Thanks for all the help
Yes. cat, touch etc all give a default file permission of 666.
thanks a lot!