LinuxQuestions.org
Register a domain and help support LQ
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 04-30-2014, 02:31 AM   #1
sigint-ninja
Member
 
Registered: Feb 2011
Location: Republic Of Ireland
Distribution: Debian,Centos,Slackware
Posts: 451

Rep: Reputation: 29
I dont understand something about file permissions


Hi guys,

need some help on something im reading in a book

they give this file example:

-r---w---x 1 bob proj 282 Apr 29 22:06 file1

then they say:

Let us assume that the bob user is a member of the proj group. In this case, the file called file1 in the preceding output gives the user or owner of the file (the bob user) read permission, gives members of the group (the proj group) write permission, and gives other (everyone else on the system) execute permission only. Because permissions are not additive, the user “bob” shall only receive read permission to file1 from the system.

This doesnt make sense to me...

1) What do they mean that permissions are not additive?
2) If Bob is a member of the proj group, and the proj group has write rights, should he not have write rights on the file1.

thanks
 
Old 04-30-2014, 02:44 AM   #2
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 6,008

Rep: Reputation: 1621Reputation: 1621Reputation: 1621Reputation: 1621Reputation: 1621Reputation: 1621Reputation: 1621Reputation: 1621Reputation: 1621Reputation: 1621Reputation: 1621
"Permissions are not additive" means that if you are named as the owner, as in the example, the permissions given to members of any group you are in or to everyone do not apply.
 
Old 04-30-2014, 11:20 AM   #3
ondoho
Senior Member
 
Registered: Dec 2013
Posts: 4,176

Rep: Reputation: 837Reputation: 837Reputation: 837Reputation: 837Reputation: 837Reputation: 837Reputation: 837
i find the example unrealistic.
you can take a look at your own files with
Code:
ls -l
and compare how that differs if you look at your home folder or some thing in, say, /boot.
 
Old 04-30-2014, 02:50 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
It goes to HOW permissions are evaluated

1a. are you the owner?
1b. do you have owner permission for the desired access?

2a. if not the owner, is the group specified by the file in your group list?
2b. do you have group permission for the desired access?

3. do you have world permission for the desired access?

ONLY one of 1, 2, or 3 paths is taken. It stops with the first one that succeeds. 1a - the owner test succeeds then only 1b determines success., 2a - if the group member ship succeeds, then only 2b determines sucess. If 1a and 2a both fail then only 3 applies.
 
2 members found this post helpful.
Old 04-30-2014, 10:49 PM   #5
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mint, OpenBSD
Posts: 11,350
Blog Entries: 12

Rep: Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731Reputation: 2731
I had been using Linux for years before I ran into a clear explanation of the permissions in the output of lx -l.

Unfortunately, I can't share that explanation, as it was a proprietary bit of a training program, but this article from the Arch wiki does a pretty good job:

https://wiki.archlinux.org/index.php...and_attributes
 
Old 05-05-2014, 11:27 AM   #6
sigint-ninja
Member
 
Registered: Feb 2011
Location: Republic Of Ireland
Distribution: Debian,Centos,Slackware
Posts: 451

Original Poster
Rep: Reputation: 29
thank you all oh so much...
 
Old 01-06-2015, 01:41 AM   #7
sigint-ninja
Member
 
Registered: Feb 2011
Location: Republic Of Ireland
Distribution: Debian,Centos,Slackware
Posts: 451

Original Poster
Rep: Reputation: 29
so 273 wrote ""Permissions are not additive" means that if you are named as the owner, as in the example, the permissions given to members of any group you are in or to everyone do not apply."

is this correct? is it a general rule of thumb?
 
Old 01-06-2015, 04:23 AM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,122

Rep: Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270Reputation: 2270
yes, it is correct:
1: if you are the owner the first group of permissions (rwx) will be used, nothing else.
2. if you are not the owner, but belong to the group the second group of permissions (rwx) will be - only - used.
3. otherwise the third group of permissions (rwx) will be taken.
 
Old 01-06-2015, 08:43 AM   #9
vincix
Member
 
Registered: Feb 2011
Distribution: Centos 6.7, 7
Posts: 514

Rep: Reputation: 48
Quote:
Originally Posted by ondoho View Post
i find the example unrealistic.
you can take a look at your own files with
Code:
ls -l
and compare how that differs if you look at your home folder or some thing in, say, /boot.
The example is supposed to be didactic, not realistic. And for that purpose, it's a pretty good example.
 
1 members found this post helpful.
Old 01-06-2015, 12:30 PM   #10
Miati
Member
 
Registered: Dec 2014
Distribution: Linux Mint 17.*
Posts: 326

Rep: Reputation: 106Reputation: 106
The "human readable" permissions has never made much sense to me.
Octal makes a lot more sense. You only really need to be able to add to 7.

1 = execute

2 = write

4 = read

In permissions there are three numbers (actually 4, but we'll ignore that) which could be:
750

the first is the Owner of the file (the 7), the second is the group of the file (the 5) and the third is everyone else (the 0)
This means the owner can execute (1) + write (2) + read (4) the file. = 7
The group can execute (1) + read (4) the file = 5
Everyone else can do nothing (0)

You can change these in any way. Want groups to read and write but not execute? Add 2+4. So we should do 760.

To make it easy for me to see permissions in octal I use my own perm function as opposed to ls -l
Code:
alias perm="stat -c '%n %U:%G-%a'"
perm file
file miati:miati-644 or filename owner:group-octal_permissions
 
Old 01-06-2015, 06:30 PM   #11
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
It is quite simple:
Code:
1 = execute = x
2 = write   = w
4 = read    = r
Since the values are combined via an or:
Code:
octal binary mnemonic
   4 = 100    r
   2 = 010    w
   1 = 001    x
   --
   7 = 111    rwx
 
Old 01-06-2015, 08:02 PM   #12
sumncguy
Member
 
Registered: Jun 2013
Posts: 71

Rep: Reputation: Disabled
See the attached for a visual illustration of permissions.


Other items of interest:

"permission of all parent directories must be considered before considering permissions on a file."
Attached Thumbnails
Click image for larger version

Name:	Selection_010.png
Views:	13
Size:	24.8 KB
ID:	17290  
 
  


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
Is it just me, or is Linux file-permissions incredibly simple to understand? lumix Linux - Newbie 6 12-18-2008 12:55 AM
Permissions error message I dont understand? BajaNick Linux - Security 5 02-16-2005 09:12 PM
can't load mandrake, says i dont have file permissions? wtf! agh help plz rApT0r Linux - Newbie 2 04-11-2004 04:26 PM
Dont Understand Sifvion Slackware 27 03-26-2003 02:49 PM
Things dont work when you dont understand withoutaclue Linux - Newbie 3 03-12-2003 10:51 AM


All times are GMT -5. The time now is 10:49 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