folder permission & file nested in a folder - which have the ultimate said ?
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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 ?
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
-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
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.
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.
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
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 ..
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.