Do files inheret the permissions fo the folder they are placed into?

Say I download a file and place it into a shared folder where other users can read and execute files. Will the files inherit the permissions of that folder or will I have to change the permissions on those files as I add them to that folder?

Not normally. Only if you use ACL inheritance.

And be clear whether you are referring to ownership or permissions. When I write permissions I mean the read, write and execute capabilities. Some people lump ownership into that. That’s misleading.

Also a different set of rules apply if you are going through a service like Samba.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Default file permissions are calculated by the user’s umask (for
permissions) as well as some special properties of the directory (for
example, the SGID bit on a directory). There are also some fun options
with extended ACLs (facls) which make life interesting.

If you want all files in a specific directory to be group-owned by the
same user make that user the group-owner of the directory itself and then
add the SGID bit as follows:

chmod g+s /path/to/your/directory

Now any files created in there, by anybody, will be group-owned by the
same group that owns the directory itself, so you have a location where
all files can be seen (usually, in normal cases) by all members of that group.

Good luck.

On 10/28/2010 11:36 PM, FlameBait wrote:
>
> Say I download a file and place it into a shared folder where other
> users can read and execute files. Will the files inherit the permissions
> of that folder or will I have to change the permissions on those files
> as I add them to that folder?
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJMymOFAAoJEF+XTK08PnB5kHMP/0pB5ApvWBnq2vpX4s+UmuFC
M7d3UW1z9NDoV/vmWg+0lPXtaZd3kM34A05/AATEFljZHTByl8QKLUjX977MseNk
g/a2lomhQh/DAcDITcdDyMEXyl1TcnQsiNBGVhQQLE8HO8jqYJQNl9hoS8RLW3Jw
U6AFFXiL+tskErBuA/wa5byhExa3rrwuZ7ZG8gNGneP7yNT/PNrBWtw0i/LztDuy
ncNz73SnOgaEW2ixVOhW00WgB1TNvNImCloLRQTOi6uq2OtU8cZZMQtoIlCwlceu
+PSzV9+B/CrGw27SfwfacUIQn3/kLlCwV1feeX7BKYXYrMLFZdZPnbT8QFD4C3bN
okwpVEUDT/wp321G5Yd0uVLdzlMLl1bbaMkMtSulKtKQKlR+/SFsBbq7D1sX2HCl
ZlTlcKMA1zaYCeTzs+uuRU4kAB267ReBoVk3GnmoxGAt3d/jXATX8YXP4hBO5Kpa
p5djpBrFUEJM9DiNj7v3KrnO/lHmrvc9wnV91CNd/AvDQGgM+uYsL3pyZr7GtflD
gAZg6z7qFPo/96eIVsiM6SC0WCJZjNyN5qsYTgAPkdNdbXyaNpCBcd2RwwPCMTxP
szpPUOgQTwR6PK8gvW4cTb8vL7eWq59vpiAxKN/+sLfiyRodEi1DtyYn94Nj0bVA
XRL0pYXygGubIA4J3wpK
=L5od
-----END PGP SIGNATURE-----

Yes I am talking about r w x belonging to me and giving someone else the permission to read them. I had the same user IDs across all my machines previously so this wasn’t a issue now I have this test box I built I am seeming to have to go and manually change the permissions for the previously shared NFS directories. Since things are shared via NFS in reality all that can be done is reading of a file since it’s defaulted to read only. These are media files so the player can’t play them if the ownership is wrong.

From what I understand you saying If I set a directory so a group can view(read) and others can view and I drop a file into that directory I will have to change the permissions on the file as they go in. It will not inherit the permissions of the folder.

I may change the user id in YAST to match the host machines so I can forgo having to do that.

Yes, in this case the permissions on the file are determined by the combination of the create mode chosen by the program (usually 0666 for non-executables) anded with the inverse of the umask in effect at that time.

The thing to remember is that umask can only take away permissions not add permissions. For that you need ACLs.

Also access to a file or directory is allowed based on traversal of the permissions of all intervening directories from /.

One hassle with NFSv3 is that for best results, uids should be uniform throughout. Perhaps you should harmonise the uids on all boxes. Or use NFSv4, but that has setup hassles.

On 2010-10-29 09:06, ken yap wrote:

> One hassle with NFSv3 is that for best results, uids should be uniform
> throughout. Perhaps you should harmonise the uids on all boxes. Or use
> NFSv4, but that has setup hassles.

Quick question: Can NFSv4 map users? Like user john, uid 1000 in the server, be user john (or
mark), uid 2000 in the client.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)

Don’t quote me but IIRC NFSv4 has authentication and mapping of connections (all TCP now) to uid@domain where the server and client must belong to the same domain, thus not using the native Linux account uid, or so I understand it.

LinuxPlanet - Reviews - NFSv4: A Unix Mainstay Learns New Tricks - Linux NFS Efforts Progressing

I made the User ID the same on the test box and it seems to be playing well now. The user ID is 500 and was “inherited” from my old Mandriva install. openSUSE defaults to 1000.

YAST in 11.3 makes setting up NFS pretty easy as far as selecting what directories to share. Knowing the IP address of the host machine is pretty much required on the client side as discovery of NFS shares doesn’t seem to work.

Yes at some point most distros made the move from first uid = 500 to 1000 to free up room for more system uids. However long lived systems like RHEL still start at 500.

Yes, I could never make it work. Mildly frustrating.

The easy way to get the IP address of the NFS host is to log in to a terminal on the host as root and type in ifconfig. That will give you the IP address of that machine. My host is set to a static IP address and all the clients get their IPs via DHCP from my router.

You will have to have the NFS server software installed on the host as well. You can set up the host machine in YAST once the software is installed.

I usually install knetstats (still the best network activity monitor IMO) that show the address in a small window. You can also see that in knetworkmanager if you’re using it. Not that the command line isn’t easy too.