LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-08-2006, 05:03 AM   #1
>G<
LQ Newbie
 
Registered: Jun 2006
Posts: 26

Rep: Reputation: 15
Umask Query


Hi,

I wanted to clarify how I could use UMASK to control permissions and also wanted to clarify if the octal for UMASK was 0666 or 0777

Thanks
 
Old 06-08-2006, 05:16 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
don't understand what you mean... 0666 and 0777 are both perfectly valid octal masks. 0666 = --x--x--x, 0777 = ---------
 
Old 06-08-2006, 03:15 PM   #3
>G<
LQ Newbie
 
Registered: Jun 2006
Posts: 26

Original Poster
Rep: Reputation: 15
What I meant was, assuming I just installed a distribution e.g. Red Hat, Suse, etc, would UMASK permissions be based on the octal 0666 or 0777. I would have thought its the latter.

Also what's the benefit of using UMASK when I can use CHMOD?
 
Old 06-08-2006, 03:30 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
a default umask is normally 022 for user group based systems (you share a group, e.g "users"), 002 for own group based systems (i.e. your group is private to you)

umask is generally used for default file creation rights, whereas chmod is for changing rights explicitly on existing files.

and it's case sensitive, stop saying "UMASK"
 
Old 06-08-2006, 03:56 PM   #5
>G<
LQ Newbie
 
Registered: Jun 2006
Posts: 26

Original Poster
Rep: Reputation: 15
a default umask is normally 022 for user group based systems (you share a group, e.g "users"), 002 for own group based systems (i.e. your group is private to you)

What do you mean by "user group based systems (you share a group, e.g "users")" and "own group based systems (i.e. your group is private to you)"

Assuming the default is 022 and 002, are the permissions based on an octal value of 0666 or 0777 i.e. if it's 0666 then the permissions would be 644 and if it's 0777 then the permissions would be 775.

I only capitalized UMASK to make it stand out from the rest of the query. I apologise.
 
Old 06-08-2006, 04:02 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
022 and 002 ARE octal....
 
Old 06-08-2006, 06:10 PM   #7
>G<
LQ Newbie
 
Registered: Jun 2006
Posts: 26

Original Poster
Rep: Reputation: 15
Sorry I think I am not being clear in my query.

1) Assuming that the default user umask is 022
2) Assuming that the default group umask is 002
3) Based on assumption (1) would my permissions read 644 or 775?
4) What do you mean by "user group based systems (you share a group, e.g "users")" and "own group based systems (i.e. your group is private to you)"
 
Old 06-08-2006, 06:16 PM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
1) nope... in a umask of "022" the user mask is "0", the first digit
2) nope... in a umask of "002" the group mask is "0", the second digit
3) 777 - 022 = 755
4) some distro's (e.g. gentoo) have a common "user" group. others like fedora ignore the groups and have a 1 to 1 membership so the group bit is the same as the user bit.
 
Old 06-09-2006, 04:17 PM   #9
>G<
LQ Newbie
 
Registered: Jun 2006
Posts: 26

Original Poster
Rep: Reputation: 15
1) nope... in a umask of "022" the user mask is "0", the first digit
2) nope... in a umask of "002" the group mask is "0", the second digit
3) 777 - 022 = 755
4) some distro's (e.g. gentoo) have a common "user" group. others like fedora ignore the groups and have a 1 to 1 membership so the group bit is the same as the user bit.

Sorry I really don't understand what you meant by

1) in a umask of "022" the user mask is "0", the first digit > What does it represent and where would I use it?

2) in a umask of "002" the group mask is "0", the second digit >What does it represent and where would I use it?

3) Why do some online examples use 0666 then rather than 0777?

4) Do you mean a UPG - User Private Group where the user belongs to his/her onw group when his/her account is first created?
 
Old 06-11-2006, 01:42 AM   #10
>G<
LQ Newbie
 
Registered: Jun 2006
Posts: 26

Original Poster
Rep: Reputation: 15
Can someone please help as I keep getting conflicting answers to my questions (not in particular this thread but in relation to the answer here to the articles online)?

Thanks
 
Old 06-11-2006, 02:03 AM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Well ... it doesn't get much clearer than what Kewp said. Maybe
you're asking in the wrong way, or have a basic misapprehension as
to what the umask DOES? Read the reference in Rute, for instance,
or just let what Kewp said sink in.


Cheers,
Tink
 
Old 06-12-2006, 12:15 AM   #12
>G<
LQ Newbie
 
Registered: Jun 2006
Posts: 26

Original Poster
Rep: Reputation: 15
Sorry but it didn't answer my questions below.

1) in a umask of "022" the user mask is "0", the first digit > What does it represent and where would I use it?

2) in a umask of "002" the group mask is "0", the second digit >What does it represent and where would I use it?

3) Why do some online examples use 0666 then rather than 0777?

4) Do you mean a UPG - User Private Group where the user belongs to his/her onw group when his/her account is first created?
 
Old 06-12-2006, 01:05 AM   #13
worzel68
Member
 
Registered: May 2006
Location: Sydney
Distribution: FC5, FC3, AIX, System V,
Posts: 50

Rep: Reputation: 15
>G<
I think you need to understand a bit more about how permissions work, because there a couple of ways they described or changed.

First, Every file has an owner and a group associated with it. Permissions are split into 3 sections - owner, group & public. Each of these can have a possible read, write or execute permission. These permissions can be expressed in character format or octal.

Here is an example of the character format:

Quote:
[dave@cpe-147-10-189-254 ~]$ ls -ld Desktop
drwxr-xr-x 2 dave dave 4096 Jun 10 16:14 Desktop
I used the l option to get a long listing, and the d option bcause I listed a directory.
These are the permissions:

Quote:
drwxr-xr-x
the d means it's a directory.
the next 9 characters show the permissions for owner, group and public.
the owner has read, write, execute permission for the directory.
anyone who belongs to the group has read and execute permission only.
Anyone else only has read and execute permission.

Now for the Octal part:

The permissions could be expressed in decimal by allocating a 4 for read, a 2 for write, and a 1 for execute.
To make it easier they can be expressed in Octal by adding them together for each of owner, group, public.

777 = read, write, execute for every one.
666 = read, write for every one but not execute.

So, rwxr-xr-x equals 755.

This shows that on my system the umask is 022 (for directories) because 777 - 022 = 755

One would use umask to set the default permissions automatically every time a file or directory is created.

chmod is used to alter the permissions after the file is created.

Quote:
drwxr-xr-x 2 dave dave
This shows that the owner is dave & the groupname is also dave. This where the user has their own group.

The reason why we have groups, is to make it easier to set permissions for lots of users at once. In a work situation, where you might have arhitects, engineers & planners, there would be a group for each of these, and each user would be placed in their appropriate group. Then, an administrator would set the group & group permissions for the directories & files nedded by a group. This way the admin can control access, so that for example, the planners can't get into the Engineers files & vice versa.

I hope that all this explains things clearly.

Last edited by worzel68; 06-12-2006 at 02:09 AM.
 
Old 06-12-2006, 05:49 AM   #14
>G<
LQ Newbie
 
Registered: Jun 2006
Posts: 26

Original Poster
Rep: Reputation: 15
worzel68,

Thanks for your reply and I do understand that Linux like any other server OS is permissions driven. What I was questioning were the comments which (1) and (2) were made by acid_kewpie

1) in a umask of "022" the user mask is "0", the first digit > What does it represent and where would I use it?

2) in a umask of "002" the group mask is "0", the second digit >What does it represent and where would I use it?

3) Why do some online examples use 0666 then rather than 0777?

I take it that it's alway 0777 - umask (value) rather than 0666. I do appreciate your detailed explaination and it gave me a better understanding as to why I would want to use umask i.e. set a default permission criteria every time a file or folder is created.
 
Old 06-12-2006, 06:04 AM   #15
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
The core utils manual explains permissions.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
When and why to use Umask ? tofee Linux - Newbie 4 11-26-2009 10:21 AM
what is Umask ? tofee Linux - Newbie 1 03-23-2006 08:05 AM
what is umask osmansm Linux - Newbie 11 12-09-2005 01:30 PM
Umask metallica1973 Linux - Software 4 11-27-2005 02:21 PM
umask knueven7 Linux - Newbie 8 04-18-2003 08:30 AM


All times are GMT -5. The time now is 10:41 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration