Solved

Say I have a umask of 44 what will be the permissions of newly created file myfile

Posted on 2010-11-28
5
1,133 Views
Last Modified: 2012-05-10
Say I have a umask of 44 what will be the permissions of newly created file myfile
0
Comment
Question by:sobeservices2
[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
5 Comments
 
LVL 11

Expert Comment

by:dougaug
ID: 34226145
user = rw
group = w
others = w

rw- -w- -w-
0
 

Author Comment

by:sobeservices2
ID: 34226166
dougaug could you explain your answer a little more

umask creates directory permissions right?

not file permissions?
0
 

Assisted Solution

by:tomy123
tomy123 earned 166 total points
ID: 34226325
When you set the umask as 44 then the default permission for directories will be as follows
u=rwx,g=wx,o=wx

user- read,write,and execute
group-write and execute
others- write and execute

For the case of files the permission will be as follows
rw--w--w-

User- read and write
group = write
others = write

0
 
LVL 11

Accepted Solution

by:
dougaug earned 167 total points
ID: 34226357
When creating files or directories in unix systems, unix combine full access modes for files and directories with "inverted" user mask like below to set permissions (full access mode for files is u=rw-,g=rw-,o=rw- or 666 in octal and for directories it is u=rwx,g=rwx,o=rwx or 777 in octal).

umask=044 (in binary 000 100 100) -> First octet is for owner permissions, second is for group and third for others. First byte (from left to right) is for read permission, second is for write and third is for execute.

When creating a file:
full access mode           = 666 (in binary 110 110 110)
umask                           = 044 (in binary 000 100 100)
Inverting bits in umask = 633 (in binary 111 011 011)

Set file permissions bitwise anding full access mode with inverted umask:
full access mode -> 110 110 110
bitwise and
Inverted umask  -> 111 011 011
permissions        -> 110 010 010
                                rw- -w-  -w-


When creating a directory:
full access mode           = 777 (in binary 111 111 111)
umask                           = 044 (in binary 000 100 100)
Inverting bits in umask = 633 (in binary 111 011 011)

Set file permissions bitwise anding full access mode with inverted umask:
full access mode -> 111 111 111
bitwise and
Inverted umask  -> 111 011 011
permissions        -> 111 011 011
                                rwx -wx -wx
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 167 total points
ID: 34226540
Easiest way to work it out is either by just trying it, or doing the calculation

For a file it's

666
044
-----
622

For a directory it's

777
044
-----
733
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

705 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