Home > Back-end >  Unable to change directory or file permission [chmod question]
Unable to change directory or file permission [chmod question]

Time:07-23

I am trying to change the permission of a file to 444 (read-only).

This directory resides in a NTFS drive. All files in this drive seem to be owned by root.

This is the present permissions for the directory.

drwxrwxrwx 1 root root 0 Jul 23 11:41 xxx_directory

I've tried sudo bash and then execute chmod 444 xxx_directory to no avail.

The expected outcome was dr--r--r-- for xxx_directory.

Thoughts? Thank you.

CodePudding user response:

The directories need at least R-X

First, create a mount point in a terminal using 'mkdir'. Then, type the following line to mount the partition with options 'permissions': sudo mount /dev/sdXN -t ntfs-3g -o permissions [Mount point]

Example:

sudo mount /dev/sdb1 -t ntfs-3g -o permissions /media/Data/

Then, you will be able to edit the permissions of the files on the NTFS partition with 'chmod' and 'chown' !

Check thia reference LINUX - MOUNT NTFS PARTITION WITH PERMISSIONS

CodePudding user response:

You should at least require the x permission for directories otherwise you won't be able to cd into it.

You can specify the permissions (via fmask and dmask) while mounting the partition ( or in fstab if an entry is there).

An example of an fstab entry :

#mounting by UUID
UUID=<partition UUID> /mount/point ntfs-3g user,uid=1000,gid=1000,dmask=0022,fmask=0033

This would give all directories in that partition drwxr-xr-x parmissions. Any file created will get .rw-r--r-- permissions. And the ownership would be by the user with uid 1000 so he can change permissions (without sudo)

  • Related