LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-25-2003, 10:50 PM   #1
danahata
Member
 
Registered: Aug 2003
Posts: 30

Rep: Reputation: 15
simple umask question


Ok I do umask 0333, and then touch a file, and the file gets created with permissions of -r--r--r--, which is 0444. I thought that the file permissions are determined internally by ANDing the umask with another value, such as 0666 or 0777. But there is nothing that 0333 can be ANDed with to produce 0444. What am I missing here?


Dana
 
Old 08-25-2003, 11:04 PM   #2
Skyline
Senior Member
 
Registered: Jun 2003
Distribution: Debian/other
Posts: 2,104

Rep: Reputation: 45
A umask=0333 will give you

-r--r--r--

A umask=0444 will give you

--wx-wx-wx

You would typically set a umask value globally for all new files and directories created - locally you would typically use chmod
 
Old 08-25-2003, 11:32 PM   #3
shellcode
Member
 
Registered: May 2003
Location: Beverly Hills
Distribution: Slackware, Gentoo
Posts: 350

Rep: Reputation: 32
$man umask | grep 666
666 & ~022 = 0644 = rw-r--r-- in the usual case where is mode is specified as 0666

666 - 022 = 644
you subtract the umask from 666 to get the permissions.
 
Old 08-26-2003, 09:27 AM   #4
danahata
Member
 
Registered: Aug 2003
Posts: 30

Original Poster
Rep: Reputation: 15
Ok, so the real answer is that the file permissions are determined this way -->

0666 AND (NOT umask)

Dana
 
Old 08-26-2003, 09:47 AM   #5
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
almost,

file_permision = requested_permision AND (NOT umask)

so with a umask of 022, trying to create a file with permission 777 will give it 755. requested permision is not necessarily 666 which you seemed to assume above.
 
Old 08-26-2003, 10:34 AM   #6
danahata
Member
 
Registered: Aug 2003
Posts: 30

Original Poster
Rep: Reputation: 15
Ok, I thought I had it- now I'm confused again. I guess I don't understand the concept of 'requested permission' as you described. What is it and how is it set? (Also why do you need it?) I guess I thought that the umask was a form of requested permissiion.

Dana
 
Old 08-26-2003, 10:55 AM   #7
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
sorry, what i said is unimportant, requested permission defaults to 0666 when creating files and 0777 when creating directories. so if you create a directory with umask 002 it will have permision 775

if you are programming when you create a file or directory you have to specify what permissions you want the file to initially have, this is what i mean by requested permission, however ive just checked and touch and mkdir dont let you choose this, they use 0666 and 0777 respectivly
 
Old 08-26-2003, 11:01 AM   #8
danahata
Member
 
Registered: Aug 2003
Posts: 30

Original Poster
Rep: Reputation: 15
Ok I've got it now.

For FILES:

file permission = 0666 AND (NOT umask)

I hope this helps others!

Dan
 
Old 08-26-2003, 11:04 AM   #9
Skyline
Senior Member
 
Registered: Jun 2003
Distribution: Debian/other
Posts: 2,104

Rep: Reputation: 45
You can change the default umask value in /etc/profile.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vsftp umask question bkali4nia Linux - Software 11 12-31-2013 02:59 AM
Ubuntu Fluxbox simple question, simple answer? generallimptoes Linux - Software 3 09-26-2005 02:03 PM
Installing Programs - A simple question from my simple mind jmp875 Linux - Newbie 6 02-18-2004 09:03 PM
ProFTPD Umask question..... hct224 Linux - Newbie 2 10-21-2003 10:03 AM
umask Question gauge73 Linux - Newbie 2 07-09-2003 07:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration