LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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-23-2022, 05:56 PM   #1
andrewysk
Member
 
Registered: Mar 2020
Posts: 797

Rep: Reputation: Disabled
folder permission & file nested in a folder - which have the ultimate said ?


What will happen to the file (test.txt) when it is placed in a folder that have full permission to all users (note: file test.txt only have read write permission to the owner)?

ls -lhd testfolder
drwxrwxrwx 2 user1 user1 4,0K Feb 24 00:46 testfolder


ls
-rw-r--r-- 1 user1 user1 0 Feb 24 00:45 test.txt

The file permission has higher priority over the folder permission ?
What is the point to assign folder permission since the content (files) of it does not inherit permission from the folder ?

Thx
 
Old 02-23-2022, 06:54 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,591

Rep: Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689
The two sets of permissions are over different things.

Before I go on, is this homework?
 
Old 02-24-2022, 04:33 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by andrewysk View Post
What will happen to the file (test.txt) when it is placed in a folder that have full permission to all users (note: file test.txt only have read write permission to the owner)?

#ls -lhd testfolder
drwxrwxrwx 2 user1 user1 4,0K Feb 24 00:46 testfolder


#ls
-rw-r--r-- 1 user1 user1 0 Feb 24 00:45 test.txt

The file permission has higher priority over the folder permission ?
What is the point to assign folder permission since the content (files) of it does not inherit permission from the folder ?
There's no prority here, the file has different permissions from the folder, full stop.
Ownership and group membership are also important when you look at permissions.

BTW, my folders have only 755 permissions, I wonder why your's is 777.

Quote:
Originally Posted by wpeckham View Post
Before I go on, is this homework?
Unlikely, this person is asking similar questions all the time. Curious, but apparently unable to look up even the simplest stuff. It must be horribly unsatisfying, but there it is.

PS and OT: had to add # to ls otherwise cloudflare starts its shenanigans again.

Last edited by ondoho; 02-24-2022 at 04:34 AM.
 
Old 02-24-2022, 10:44 AM   #4
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,591

Rep: Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689
Remember that in the Unix world, everything is a file. There are property distinctions, but in many ways everything is like a file for some purposes. In this case the permission on the file determine what you can do with the contents of the file (read, write, execute), permissions on the folder determine what you can do with the contents of the folder.

The file holds data, and if you can READ it you can see the data, otherwise you cannot. If you have permissions to WRITE the file you can change the contents, otherwise you cannot.
The folder holds the file, and if you have no permissions to write the folder you can still manipulate the file based upon the file permissions, but you may not be able to DELETE the file if you have no WRITE permissions on the folder as that would require write permission on the folder.
Write permissions on the object give you permission to change the contents. Read permissions allow you to view them, execution permission on objects that are not a simple file with code contents are less intuitive, but you can look that up.
The permissions are ONLY on the object, and there is no inheritance effect of the permissions (though there may be cascading implications).

It all makes good sense if you think of it the right way, and remember that Unix objects are unrelated to objects in the programming sense. These objects predate Python, Java, and even Smalltalk, (actually the concepts and structures predate Unix a bit) and follow rules that made (and make) sense for the OS.
 
2 members found this post helpful.
Old 02-24-2022, 03:14 PM   #5
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
A very short version of permissions:-
Attached Thumbnails
Click image for larger version

Name:	permissions.png
Views:	34
Size:	19.6 KB
ID:	38462  
 
1 members found this post helpful.
Old 02-24-2022, 04:57 PM   #6
andrewysk
Member
 
Registered: Mar 2020
Posts: 797

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by wpeckham View Post
The two sets of permissions are over different things.

Before I go on, is this homework?
No, it is not homework. I just suddenly puzzle of it when i was reading and trying out chmod command..
 
Old 02-24-2022, 05:11 PM   #7
andrewysk
Member
 
Registered: Mar 2020
Posts: 797

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ondoho View Post

BTW, my folders have only 755 permissions, I wonder why your's is 777.
Huh ?
Can't owner group and other have the write permission to a folder ? Are you testing me ? lol
Quote:
Originally Posted by ondoho View Post
Unlikely, this person is asking similar questions all the time. Curious, but apparently unable to look up even the simplest stuff. It must be horribly unsatisfying, but there it is.
Sorry. There is that much of stuff to read. I think I started using linux a bit too late.. :-) my memory is failing me sometime.. no matter how much note i made and how eager i want to master it.. sometime just too much ..
 
Old 02-24-2022, 09:35 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
755 vs 777 : principle of least privilege.
Never give perms that aren't reqd(!) for the required functionality to work.

Just because you can, doesn't mean you should
 
2 members found this post helpful.
Old 02-25-2022, 09:20 AM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,647
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
Permissions for directories determine if their contents can be read or modified. Effectively, they determine whether a file can be found.

Permissions for non-directories then determine if and how those things can be used.

You should also be aware that most Linux filesystems also support ACLs = Access Control Lists, which offer considerably more fine-grained access controls. The PAM = Programmable Authentication Modules kernel facility can take this even further.

If you are using a remote, or a foreign, filesystem, then "things can get a bit strange" because now the rules are dictated by the foreign system – and, well, "Linux is a 'foreigner.'" For instance, Microsoft's "NTFS" system is deeply built around Microsoft's role-based security model, which a Linux foreigner can only approximate.

Last edited by sundialsvcs; 02-25-2022 at 09:23 AM.
 
Old 02-25-2022, 10:13 AM   #10
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
If you have write access to a folder, even if you don't own it:-
then...

You can delete or rename any file in the folder, regardless of any file access rights.
However, if you want to access or alter the contents of a file, then you will need appropriate file access rights.
 
Old 02-25-2022, 11:37 AM   #11
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by andrewysk View Post
Sorry. There is that much of stuff to read. I think I started using linux a bit too late.. :-) my memory is failing me sometime.. no matter how much note i made and how eager i want to master it.. sometime just too much ..
No need to apologize - it's not my problem.
If your memory is failing you, well that's exactly what man pages & documentation are there for!
Imagine having to look up things in forum posts instead of documentation... considering your argument, that's definitely worse.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] umount said /dev/sdd is not mounted; yet lsblk said it is mounted to /run/media/ ? andrewysk Linux - Newbie 8 05-29-2021 04:29 PM
LXer: Ultimate Edition 3.4 has been released with ultimate Features LXer Syndicated Linux News 0 07-03-2012 07:10 AM
I said, "howdy;" she said, "hi." NoTinyFlacid LinuxQuestions.org Member Intro 1 11-21-2010 08:27 PM
LXer: Ultimate Edition: Not so ultimate LXer Syndicated Linux News 0 06-06-2008 04:41 PM
Gotta love those ٱٱٱٱٱٱٱ&# iLLuSionZ Linux - General 5 11-18-2003 07:14 AM

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

All times are GMT -5. The time now is 09:03 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
Open Source Consulting | Domain Registration