Solved

umask

Posted on 2004-08-12
3
467 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
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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
low latency kernel configuration 3 173
IPtables not running - RHEL7 64bit 5 236
Need bundled ATFTP tool for use with ESXi 4 84
Problem to line 1 45
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 fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now