# Permission on NFS share

**URL:** https://community.unix.com/t/permission-on-nfs-share/381041
**Category:** UNIX for Advanced & Expert Users
**Created:** [December 9, 2020, 12:25pm UTC](https://community.unix.com/t/permission-on-nfs-share/381041 "2020-12-09T12:25:17Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![arm](https://community.unix.com/letter_avatar/arm/32/5_5575768a8748004e209b776fc1b2916d.png) [@arm](https://community.unix.com/u/arm)
#### Post date: [December 9, 2020, 12:25pm UTC](https://community.unix.com/t/permission-on-nfs-share/381041/1 "2020-12-09T12:25:17Z")

</div>

Hello

I'm sharing /data as nfs share with rw, secure and root\_squash options from my nfs CentOS server. when I mounted on client it works but I'm getting permission denied if I tried to create file or directory why ? Is that because I have no write permission on shared nfs ??  
and how to setup my share so newly created files would have 664 and directories would have 775 permission ??

---

<div class="post-metadata">

### Author: ![bendingrodriguez](https://community.unix.com/user_avatar/community.unix.com/bendingrodriguez/32/21971_2.png) [@bendingrodriguez](https://community.unix.com/u/bendingrodriguez)
#### Post date: [December 9, 2020, 1:37pm UTC](https://community.unix.com/t/permission-on-nfs-share/381041/2 "2020-12-09T13:37:13Z")

</div>

nfs maps the client user id to the same server user id by default. If that id hasn't write access to `/data`, your client isn't allowed to write also.  
Please submit the output of  
`ls -ldn /data # server side`  
and  
`id -u; id -g # client side`

---

<div class="post-metadata">

### Author: ![arm](https://community.unix.com/letter_avatar/arm/32/5_5575768a8748004e209b776fc1b2916d.png) [@arm](https://community.unix.com/u/arm)
#### Post date: [December 9, 2020, 5:15pm UTC](https://community.unix.com/t/permission-on-nfs-share/381041/3 "2020-12-09T17:15:30Z")

</div>

thanks , I have created the directory /data as root user on nfs server , and the permission rwxr-xr-x thus root or any user on nfs client cannot write to nfs mount unless they have 'w' permission , is that what you mean?  
and If promote the permission anyone on the share mount can remove the files or directories , should I add sticky bit to prevent ?

what about new created files and directories how to give 664 and 775 , second part of my inquiry ?

---

<div class="post-metadata">

### Author: ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)
#### Post date: [December 9, 2020, 5:33pm UTC](https://community.unix.com/t/permission-on-nfs-share/381041/4 "2020-12-09T17:33:20Z")

</div>

Most important: You haven't said what you are up to...  
Many possibilities but for that we need to know what you are trying to achieve...

How many boxes can mount?  
Should they share? IF partially give details etc...

---

<div class="post-metadata">

### Author: ![hicksd8](https://community.unix.com/letter_avatar/hicksd8/32/5_5575768a8748004e209b776fc1b2916d.png) [@hicksd8](https://community.unix.com/u/hicksd8)
#### Post date: [December 9, 2020, 5:47pm UTC](https://community.unix.com/t/permission-on-nfs-share/381041/5 "2020-12-09T17:47:59Z")

</div>

You are sharing from CentOS but what OS's are the clients running?

Have you checked that client and server NFS versions are the same? If so, what are we talking; version 2, 3 or 4?

---

<div class="post-metadata">

### Author: ![arm](https://community.unix.com/letter_avatar/arm/32/5_5575768a8748004e209b776fc1b2916d.png) [@arm](https://community.unix.com/u/arm)
#### Post date: [December 9, 2020, 5:49pm UTC](https://community.unix.com/t/permission-on-nfs-share/381041/6 "2020-12-09T17:49:24Z")

</div>

one box to one , I have server and client and that was my first time to use root\_squash , I know there's possibility to create specific user and group on server side and client side but just wanted to see the behavior without doing so.

what I need as simple as that , from client side I need any user be able to create files with 664 and directory with 775 , but others can't impact , modify or delete files / dir not belong to ...

---

<div class="post-metadata">

### Author: ![arm](https://community.unix.com/letter_avatar/arm/32/5_5575768a8748004e209b776fc1b2916d.png) [@arm](https://community.unix.com/u/arm)
#### Post date: [December 9, 2020, 5:51pm UTC](https://community.unix.com/t/permission-on-nfs-share/381041/7 "2020-12-09T17:51:24Z")

</div>

centos as well, nfs 4 is the version I'm using which is the default version if I'm not wrong but to be honest and didn't enable from /etc/nfs.conf , should I do so ??

---

<div class="post-metadata">

### Author: ![bendingrodriguez](https://community.unix.com/user_avatar/community.unix.com/bendingrodriguez/32/21971_2.png) [@bendingrodriguez](https://community.unix.com/u/bendingrodriguez)
#### Post date: [December 9, 2020, 7:29pm UTC](https://community.unix.com/t/permission-on-nfs-share/381041/8 "2020-12-09T19:29:17Z")

</div>

do all of the users have the same **primary** group (e.g. `users`) or do they all have their own?

Update/Explanation: If every user has their **own primary** group (default for Debian & CentOS), then you have to `chmod 777 /data`, otherwise `chgrp <usergroup> /data && chmod 775 /data`. This allows all users to write to `/data`. In any case, each user keeps his uid, as long as `no_all_squash` is set in `/etc/exports`, which is the default.

**But** if you want to use `umask 002` (i.e. 664/775) **and** all the users belong to the **same primary** group, then they are able to overwrite each other's data (this is independent of the above `chmod`!).

Setting `umask` is simple on client side ( **not** via mount options in fstab). On server side, nfs doesn't care about `umask`, that's only possible with ACLs, see [No acl on nfs mount in linux? - Server Fault](https://serverfault.com/questions/539568/no-acl-on-nfs-mount-in-linux).

Summarized: Do not use `umask 002` unless all users belong to **different primary** groups.

---

<div class="post-metadata">

### Author: ![vbe](https://community.unix.com/user_avatar/community.unix.com/vbe/32/266_2.png) [@vbe](https://community.unix.com/u/vbe)
#### Post date: [December 9, 2020, 9:01pm UTC](https://community.unix.com/t/permission-on-nfs-share/381041/9 "2020-12-09T21:01:56Z")

</div>

your directory should belong to something else than root (e.g. bin ) but not necessary but GID must be common to all users with access to this FS, then to avoid others deleting files that aren't theirs you must use directory stick bit, your /share perms should be 1775

About files and directory perms of files created by users, unless you use painkilling ACLs, you can only hope they have been set as default in users environment

---

<div class="post-metadata">

### Author: ![arm](https://community.unix.com/letter_avatar/arm/32/5_5575768a8748004e209b776fc1b2916d.png) [@arm](https://community.unix.com/u/arm)
#### Post date: [December 10, 2020, 6:08am UTC](https://community.unix.com/t/permission-on-nfs-share/381041/10 "2020-12-10T06:08:26Z")

</div>

as I mentioned I have created the `/data` nfs shared via `uid/gid = root/root`. I think now I managed to achieve what I want by `chmod 777 /data` and add the stick bit `chmod +t /data` . now user root can create file/dir as needed with ownership `nfsnobody/nfsnobody` which is normal as `root_squash` was set , any user can also add file/dir with his/her `'uid/gid' with only one issue if that user was created on server with different uid/gid then the ownership will be messed

---

<div class="post-metadata">

### Author: ![arm](https://community.unix.com/letter_avatar/arm/32/5_5575768a8748004e209b776fc1b2916d.png) [@arm](https://community.unix.com/u/arm)
#### Post date: [December 10, 2020, 6:12am UTC](https://community.unix.com/t/permission-on-nfs-share/381041/11 "2020-12-10T06:12:23Z")

</div>

same reply , as I mentioned I have created the `/data` nfs shared via `uid/gid = root/root`. I think now I managed to achieve what I want by `chmod 777 /data` and add the stick bit `chmod +t /data` . now user root can create file/dir as needed with ownership `nfsnobody/nfsnobody` which is normal as `root_squash` was set , any user can also add file/dir with his/her `'uid/gid' with only one issue if that user was created on server with different uid/gid then the ownership will be messed

---

<div class="post-metadata">

### Author: ![bendingrodriguez](https://community.unix.com/user_avatar/community.unix.com/bendingrodriguez/32/21971_2.png) [@bendingrodriguez](https://community.unix.com/u/bendingrodriguez)
#### Post date: [December 10, 2020, 6:57am UTC](https://community.unix.com/t/permission-on-nfs-share/381041/12 "2020-12-10T06:57:50Z")

</div>

> [@](#):
>
> with only one issue if that user was created on server with different uid/gid then the ownership will be messed

for this you have to give each corresponding user the same id on server side with `usermod -u uid -g gid user`, but watch out for duplicate ids. Maybe [linux - NFS user mapping - Server Fault](https://serverfault.com/questions/520276/nfs-user-mapping) will also help.

---

<div class="post-metadata">

### Author: ![arm](https://community.unix.com/letter_avatar/arm/32/5_5575768a8748004e209b776fc1b2916d.png) [@arm](https://community.unix.com/u/arm)
#### Post date: [December 10, 2020, 7:30am UTC](https://community.unix.com/t/permission-on-nfs-share/381041/13 "2020-12-10T07:30:25Z")

</div>

everything looks fine now , thank you

---

<div class="post-metadata">

### Author: ![system](https://community.unix.com/uploads/default/original/2X/c/c7e9e16a595259edafe88615719d5c5dcda035c2.png) [@system](https://community.unix.com/u/system)
#### Post date: [March 10, 2021, 7:31am UTC](https://community.unix.com/t/permission-on-nfs-share/381041/14 "2021-03-10T07:31:12Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
