# Parent permission



## manefesto (Oct 5, 2010)

Hi.
I have folder /share with permission nobody:nogroup (for samba). When I copy files/folders as root then permission changes. How make automatical set permission that parent folder ?


----------



## Savagedlight (Oct 5, 2010)

See chmod(1), more specifically the part about setuid.


----------



## SirDice (Oct 5, 2010)

Don't copy the files as root. Root will override any permissions.


----------



## manefesto (Oct 5, 2010)

But if I download torrent via transmission started as user transmission then permission set transmission:transmussio for example.
Need inheritance all permission as parent folder.


----------



## SirDice (Oct 5, 2010)

manefesto said:
			
		

> But if I download torrent via transmission started as user transmission then permission set transmission:transmussio for example.


Again, root overrides all permissions. A normal user doesn't.


> Need inheritance all permission as parrent folder.


Then copy the files as a normal user, not root.


----------



## phoenix (Oct 5, 2010)

manefesto said:
			
		

> Hi.
> I have folder /share with permission nobody:nogroup (for samba). When I copy files/folders as root then permission changes. How make automatically set permission that parent folder ?



Set the 4000 or 2000 bit, aka setuid or setgid, on the parent directory. Then, any files created in that directory will pick up the user or group from the parent.


```
$ mkdir test
$ chown nobody:nogroup test
$ chmod u+s,g+s test
```

You will also need to add w permission to either the group or the "other" set, in order for non-root user to write to the directory.


----------



## leksey (Dec 6, 2013)

```
chmod u+s
```

Is Does that makes sense? For a directory, it is ignored*.*


----------



## ShelLuser (Dec 11, 2013)

leksey said:
			
		

> ```
> chmod u+s
> ```
> 
> Is Does that makes sense? For a directory, it is ignored*.*


First keep in mind that you're responding to a thread that is nearly three years old. Don't take my comment the wrong way, the only reason I mention it is because I can fully understand the confusion, I sometimes have issues with that stuff too these days.

Now; whether this is or isn't ignored depends on your kernel. FreeBSD uses the GENERIC kernel by default which tends to ignore this setting. But if you add the SUIDDIR option to the kernel configuration and then build your own kernel this will become a valid option.

Should you want to know more about building a custom kernel then you should start checking out chapter 9.5 of the handbook.


----------



## leksey (Dec 12, 2013)

Thank you. Very useful information. Sorry, that did not work out of the box.


----------

