LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 02-22-2016, 11:29 AM   #1
yolonaut
LQ Newbie
 
Registered: Feb 2016
Posts: 1

Rep: Reputation: Disabled
Permission on a file


Hi eveyone,

excuse me for my bad English.

I know that in Linux systems every file has got its own rights in a format like this:

rwx rwx rwx

The first block is for the creator, second for the group, and the third for all the others.

I know that every user is part of a group. So, if I am member of 2 groups, and I set the second block to --x, does that mean that every member of group 1 and every member of group 2 would be able to execute my file or is it limited to my primary group (the one I got in first).

Also I got an exercise regarding this topic:

Quote:
I created a shell script and I want only me and all members of one of my secondary groups to be able to execute the script. Which commands and in which order do I have to enter to get there (and the group's name is 'mygroup').
I would say chmod 110 script.sh would do the job. But I'm pretty sure that I have to work with 'mygroup' in some sort of command and I do not know why it says 'secondary group'.


Hope you guys can help out getting this sorted.
Thanks a lot!
 
Old 02-22-2016, 12:12 PM   #2
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
I know that in Linux systems every file has got its own rights in a format like this:

rwx rwx rwx

The first block is for the creator, second for the group, and the third for all the others.
That's almost correct, except that the first block is for the owner, not the creator. A file may have been created by one user but then ownership subsequently transferred to another user.

To help you understand your next point, take a sample file listing produced by ls -l:

Code:
-rwxr-xr-- 1 hydrurga seals 0 Feb 22 17:59 example
hydrurga, the owner, has "rwx" access to the file "example" (we know it's a file because of the initial '-').

Anyone in the group "seals" has "r-x" access

All the others have only "r" access

You can in fact set access rights for multiple groups using something called "extended attributes", but that is probably beyond the scope of what you're learning at the moment.

So, if you're not the owner, you have to be a member of the "seals" group to have "r-x" access - it doesn't matter what other groups you may belong to.

For the exercise you were given, have a think about how you can change the file in two ways: (i) set its group so that only 'mygroup' members have the relevant access rights; (ii) how to set those access rights, as well as those for the owner and the others.

It doesn't matter whether the group is "secondary" - all that matters is that only one group is to get group access.

I hope that this makes sense.

Last edited by hydrurga; 02-22-2016 at 12:16 PM.
 
Old 02-22-2016, 01:04 PM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,789

Rep: Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304Reputation: 7304
you may check man chmod, although it is not really trivial.
http://www.comptechdoc.org/os/linux/..._ugfilesp.html
https://www.linux.com/learn/tutorial...le-permissions
 
Old 02-22-2016, 01:15 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,776

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
The only difference between your primary group and secondary groups is that files you create will by default get your primary group ID. A non-default case would be files you create in a directory that has its set-GID bit set -- those files inherit the GID of the directory. You can use chgrp to change a file's group to any group of which you are a member.
 
1 members found this post helpful.
Old 02-23-2016, 12:16 AM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,352

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
As above, see chmod for permissions & chown or chgrp for ownerships (chgrp only changes grp ownership; chown can change owner and/or grp ownerships)
 
  


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
[SOLVED] ext4 - permission to create/modify a file without 'delete' permission BeachHead Linux - General 4 06-08-2014 07:34 PM
File & Folder Permission and Ownership permission error in Cloud storage. rhcekumaran Linux - Newbie 3 06-14-2013 04:41 AM
[SOLVED] Apache 403 file permission error when accesing a symlink file (CentOS 6.3) mkvakic Linux - Newbie 7 02-13-2013 03:25 AM
Reading ext3 file system on Mac and overriding file permission moravveji Other *NIX 6 09-12-2011 02:25 AM
Any log file for checking file permission change history in RHEL 5.1? bilalcochin Linux - Newbie 3 04-02-2010 09:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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