# Unable to change directory permission by sudo

**URL:** <https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214>\
**Category:** Newbie\
**Created:** [April 29, 2023, 7:38am UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214 "2023-04-29T07:38:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![apachecai](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@apachecai](https://forum.endeavouros.com/u/apachecai)\
**Post date:** [April 29, 2023, 7:38am UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/1 "2023-04-29T07:38:14Z")

</div>

I’m using Plasma DE. Please see screenshot below. After I executed the chmod command with sudo, the permission attributes still remained…could anyone tell me how to do it properly? I’m only able to read the files under the network share. How do I add the “write” permission?

- I made an entry under /etc/fstab (see below). I don’t know if this interfere with the chmod command.  
`//192.168.1.12/PiShare /mnt/pi4gshare cifs credentials=/home/apache/Documents/.pi4gshare_cred,iocharset=utf8 0 0`

Thank you.

![dirfirepermission](https://forum.endeavouros.com/uploads/default/original/3X/e/a/ea189646fe1af5b3f12a212c51af346e0f457ab1.png)

---

<div class="post-metadata">

**Author:** ![BendTheKnee](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/bendtheknee/32/116966_2.png) [@BendTheKnee](https://forum.endeavouros.com/u/BendTheKnee)\
**Post date:** [April 29, 2023, 8:30am UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/2 "2023-04-29T08:30:07Z")

</div>

For directories use the -R flag:

sudo chmod -R … /dir

But just make sure you don’t mess something up because it’s recursive!!

---

<div class="post-metadata">

**Author:** ![apachecai](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@apachecai](https://forum.endeavouros.com/u/apachecai)\
**Post date:** [April 29, 2023, 2:22pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/3 "2023-04-29T14:22:07Z")

</div>

I just tried -R option, outcome is the same. It didn’t change at all.

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [April 29, 2023, 2:26pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/4 "2023-04-29T14:26:59Z")

</div>

You can’t use chmod/chown on files or directories mounted via cifs. It doesn’t support POSIX permissions.

You can control that with mount options. Try adding `user` to the list of mount options.

Also, in that situation, you don’t chmod, the issue is ownership.

Lastly, never `chown -R 777`, that isn’t the right way to assign permissions. That is often irreversible and can cause serious problems. `chmod 777` isn’t how you get permissions to things.

---

<div class="post-metadata">

**Author:** ![apachecai](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@apachecai](https://forum.endeavouros.com/u/apachecai)\
**Post date:** [April 29, 2023, 2:43pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/5 "2023-04-29T14:43:38Z")

</div>

Could you please take a look at my revised entry below?

```auto

//192.168.1.12/PiShare /mnt/pi4gshare cifs rw,uid=1000,gid=1001,credentials=/home/apache/Documents/.pi4gshare_cred,iocharset=utf8 0 0

```

And, my user name “apache” is not under its own group 1001, it’s under the autologin group 1000, is that a problem?  
 ![apachegoup](https://forum.endeavouros.com/uploads/default/original/3X/1/9/19d9b7cfadb8e9d715fc91fcf86dfd2313699a19.png)

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [April 29, 2023, 2:50pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/6 "2023-04-29T14:50:08Z")

</div>

> [@apachecai](#):
>
> Could you please take a look at my revised entry below?

That will probably work as long as your uid is 1000.

> [@apachecai](#):
>
> my user name “apache” is not under its own group 1001, it’s under the autologin group 1000

That is normal. What that shows is that you are a member of the groups autologin, wireshark and nordvpn.

If you look in `/etc/passwd`, you should see that your user account has a primary group of 1001.

---

<div class="post-metadata">

**Author:** ![apachecai](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@apachecai](https://forum.endeavouros.com/u/apachecai)\
**Post date:** [April 29, 2023, 2:54pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/7 "2023-04-29T14:54:36Z")

</div>

Thank you. It works now. Just curious, why can I still execute the files in that share folder even I didn’t add the “x” after “rw” at this entry? Thanks again.

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [April 29, 2023, 2:57pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/8 "2023-04-29T14:57:19Z")

</div>

If you do an `ls -l` inside the directory, you will probably see that everything is `rwxrwxrwx`. Those are usually the default permissions if you don’t specify a `fmask` and `dmask` in the options.

---

<div class="post-metadata">

**Author:** ![apachecai](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@apachecai](https://forum.endeavouros.com/u/apachecai)\
**Post date:** [April 29, 2023, 3:01pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/9 "2023-04-29T15:01:05Z")

</div>

![2permission](https://forum.endeavouros.com/uploads/default/original/3X/1/0/101603cdac161c85cf130a5e4e8f3e907f7cef79.png)

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [April 29, 2023, 3:03pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/10 "2023-04-29T15:03:40Z")

</div>

So no write for user and group. That is a better default.

Those are directories though. Are the files also executable?

---

<div class="post-metadata">

**Author:** ![apachecai](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@apachecai](https://forum.endeavouros.com/u/apachecai)\
**Post date:** [April 29, 2023, 3:31pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/11 "2023-04-29T15:31:35Z")

</div>

1. I put an Openshot.appimage in that network share but unable to execute it. should I append “x” after “rw”? However, it doesn’t seem like a permission issue, I placed that appimage under /home but unable to execute, either. Do I need an appimage launcher for KDE Plasma?

2. after I removed the “rw,uid,gid” and add the fmask and dmask, the permission and ownership did change, see below:  
 ![3permission](https://forum.endeavouros.com/uploads/default/original/3X/a/8/a860df536458409103914862ec22c0084a7a04b8.png)

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [April 29, 2023, 3:48pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/12 "2023-04-29T15:48:09Z")

</div>

> [@apachecai](#):
>
> I put an Openshot.appimage in that network share but unable to execute it

Personally, I would not recommend running an appimage(or anything else) from CIFS share. However, to see what it wrong we would need to see an `ls -l` of the appimage.

> [@apachecai](#):
>
> should I append “x” after “rw”?

That isn’t what that does. It just controls if the volume is mounted read/write or read-only. It isn’t about file permissions.

> [@apachecai](#):
>
> I placed that appimage under /home but unable to execute, either.

After you copy it to `/home` you probably need to make it executable.

> [@apachecai](#):
>
> Do I need an appimage launcher for KDE Plasma?

No.

> [@apachecai](#):
>
> after I removed the “rw,uid,gid” and add the fmask and dmask

Why did you remove uid and gid? uid and gid control ownership and fmask and dmask control permissions. They work together.

I am not sure what you are trying to accomplish, but generally speaking you are best served to use a CIFS share for data storage and not have it be executable at all. Usually you would set something like `dmask=0022` and `fmask=0133`.

---

<div class="post-metadata">

**Author:** ![apachecai](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@apachecai](https://forum.endeavouros.com/u/apachecai)\
**Post date:** [April 29, 2023, 3:59pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/13 "2023-04-29T15:59:08Z")

</div>

I was trying to figure out what each option in the entry does, but enough for now.

The problem I have now is that there was nothing happened when I ran them under my home folder, even the permission is 777 and marked executable…so weird…it works fine on my other machine with Mint. Can you help?

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [April 29, 2023, 4:04pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/14 "2023-04-29T16:04:01Z")

</div>

Can you share an `ls -l`. Also, stop setting everything 777, that isn’t how you solve permission problems.

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [April 29, 2023, 4:23pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/16 "2023-04-29T16:23:49Z")

</div>

Please share the output from `~/Applications/OpenShot-v3.1.1-x86_64.AppImage` from the terminal?

---

<div class="post-metadata">

**Author:** ![apachecai](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@apachecai](https://forum.endeavouros.com/u/apachecai)\
**Post date:** [April 29, 2023, 4:25pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/17 "2023-04-29T16:25:40Z")

</div>

I re-downloaded then added +x and it works now. Is this the correct way to do things?

```auto
apache@7070sff ~]$ cd Applications/
[apache@7070sff Applications]$ ls -l
total 97340
-rw-r--r-- 1 apache apache 99670655 Apr 29 09:22 balenaEtcher-1.18.4-x64.AppImage
[apache@7070sff Applications]$ chmod +x balenaEtcher-1.18.4-x64.AppImage 
[apache@7070sff Applications]$ ls -l
total 97340
-rwxr-xr-x 1 apache apache 99670655 Apr 29 09:22 balenaEtcher-1.18.4-x64.AppImage

```

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [April 29, 2023, 4:26pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/18 "2023-04-29T16:26:55Z")

</div>

> [@apachecai](#):
>
> Is this the correct way to do things?

Yes. That is exactly how to do it. `chmod a+x filename`

---

<div class="post-metadata">

**Author:** ![apachecai](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@apachecai](https://forum.endeavouros.com/u/apachecai)\
**Post date:** [April 29, 2023, 4:29pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/19 "2023-04-29T16:29:48Z")

</div>

Can you point me a place I can learn each option in the entry of the /etc/fstab? I’m glad it works now but I haven’t figure out what’s really going on behind it…such as permission, uid, gid, fmask and dmask…how they cooperate/interact/restrict each other? I think having a solid understanding on these is very crucial in the long run. Thanks again for your patience!

---

<div class="post-metadata">

**Author:** ![dalto](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/dalto/32/5577_2.png) [@dalto](https://forum.endeavouros.com/u/dalto)\
**Post date:** [April 29, 2023, 4:33pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/20 "2023-04-29T16:33:01Z")

</div>

The options vary by filesystem type. The list of the options and what they do can be found in the man page. Here is an html version: [https://linux.die.net/man/8/mount.cifs](https://linux.die.net/man/8/mount.cifs)

In general, filesystems that don’t support POSIX permissions use mount options to fake them. You will similiar things in `exfat`/`vfat`/`ntfs`/etc. However, POSIX filesystems like `ext4`/`btrfs`/`xfs`/etc don’t need those options.

---

<div class="post-metadata">

**Author:** ![apachecai](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/22d042/32.png) [@apachecai](https://forum.endeavouros.com/u/apachecai)\
**Post date:** [April 29, 2023, 4:39pm UTC](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214/21 "2023-04-29T16:39:41Z")

</div>

Awesome. Where did you learn so much about Linux? not just the surface but also the rationale behind them

[Next page](https://forum.endeavouros.com/t/unable-to-change-directory-permission-by-sudo/40214.md?page=2)
