Unable to change directory permission by sudo

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

For directories use the -R flag:

sudo chmod -R … /dir

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

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

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.

2 Likes

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


//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

That will probably work as long as your uid is 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.

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.

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.

2permission

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

Those are directories though. Are the files also executable?

  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

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.

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.

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

No.

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.

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?

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

1 Like

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

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

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
1 Like

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

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!

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

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.

1 Like

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