Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

umask

Posted on 2004-08-12
3
Medium Priority
?
516 Views
Last Modified: 2010-04-21
HI,
please tell me the use of umask and its working procedure.i know it is for changing permissions of files but how it works and how it is different from chmod.
0
Comment
Question by:decentswati
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 23

Expert Comment

by:brettmjohnson
ID: 11783927
The umask specifies the default DENY permissions for future file creations,
whereas chmod modifies the permissions of existing files.  Note that, since
the umask is a deny mask, its 1s complement is ANDed with the requested
(or implied) permissions to get the final result.

http://librenix.com/?inode=4612
http://unix.about.com/library/glossary/bldef-cmd-umask.htm

Note that one lame-ass tutorial on the net describes the umask value as:
  "The logic behind the number given to umask is not intuitive."
and goes not further.  Why it shows up at the top of google's list is beyond me.

0
 
LVL 22

Accepted Solution

by:
NovaDenizen earned 150 total points
ID: 11796036
The umask controls the default permissions of files you create.  For instance, my umask is 0022, which means that the write bits for 'group' and 'other' are masked out.  By default, my files are readable by anyone, but writable only by myself.
 $ umask
0022
 $ echo hello > temp
 $ ls -l temp
-rw-r--r--    1 nova  users           6 Aug 13 14:50 temp
 $ chmod +rwx temp
 $ ls -l temp
-rwxr-xr-x    1 nova users           6 Aug 13 14:50 temp*

Notice that the write bits for 'group' and 'other' stay disabled.  The execute bits are off because of the 0022 umask.
 $ chmod 000 temp
 $ ls -l temp
----------    1 nova users           6 Aug 13 14:50 temp
 $ umask 0007
This umask turns off all bits in 'other' by default

 $ chmod +rwx temp
 $ ls -l temp
-rwxrwx---    1 nova users           6 Aug 13 14:50 temp*
chmod pays attention to the umask, and won't turn on bits in the umask unless you specifically tell it to like this:
 $ chmod o+r temp
 $ ls -l temp
-rwxrwxr--    1 nova users           6 Aug 13 14:50 temp*

To sum up:
The umask setting controls the default permissions of files as you create them.  Normal files you create are set to (0666 & ~umask), and executable files you create are set to (0777 & ~umask).
Whenever you do chmod +r, +w, or +x with no user/group/other modifiers, chmod uses the umask when it performs the chmod, and will not turn on the masked off bits.
If you use chmod to explicitly turn on a group of bits, chmod will do what you say and ignore the umask setting.
0
 
LVL 1

Author Comment

by:decentswati
ID: 11799398
HI both of u,
i am now going to finalize this question.I accept the answer of NovaDenizen because of its clearity.still for the more clearity the 2nd url of Brettmjohnson.thanks for helping me out.
bye-decentswati
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question