Page 1 of 1

<SOLVED> Removing executable permissions from text file on NTFS partition

Posted: Sat Apr 01, 2017 3:46 pm
by chellrose
I'm using Mint 17.3 Cinnamon. I have an NTFS partition which I use to access files on both Linux and Windows. I have set this partition in fstab so that it mounts with owner and group "chellrose" rather than root.

Some of the text files on this partition have executable permissions. Consequently, when I double-click one of these files in Nemo, I get a popup:
Do you want to run file.txt, or display its contents?
"file.txt" is an executable text file.
Run in Terminal, Display, Cancel, Run
I can click "Display" to open it up in my chosen text editor. I'd rather bypass that altogether and just double-click the file to open the text editor.

I have tried removing the executable permissions in terminal using

Code: Select all

chmod u-x file.txt
chmod g-x file.txt
and have also tried removing them in Nemo by unchecking the "Allow executing file as program" box in the Permissions tab of its properties. Nonetheless, executable permissions persist. The checkbox in Nemo won't clear.

I have read that chmod doesn't work on NTFS partitions. Is there an alternate way of removing the executable permissions on these files?

Thanks.

Re: Removing executable permissions from text file on NTFS partition

Posted: Sat Apr 01, 2017 4:49 pm
by altair4
Since you already have and entry in fstab for this partition add these options to your list:

Code: Select all

dmask=000,fmask=111
Then none of your files will be executable.

Or Change the behaviour of Nemo:
Nemo > Edit > Preferences > Behavior > Executable Text Files > View executable text files when they are opened

Edit: Sorry, I gave the dir/file mode for a CIFS mount not an NTFS mount but I fixed it.

Re: Removing executable permissions from text file on NTFS partition

Posted: Sat Apr 01, 2017 10:13 pm
by chellrose
I missed that option in Nemo. That fixed it, thank you!

I'm not terribly familiar with numerical permissions. Out of curiosity, does the fstab entry you gave remove executable permissions from *all* files in the partition (regardless of file type)?

Thanks again.

Re: Removing executable permissions from text file on NTFS partition

Posted: Sun Apr 02, 2017 7:15 am
by altair4
chellrose wrote:I missed that option in Nemo. That fixed it, thank you!

I'm not terribly familiar with numerical permissions. Out of curiosity, does the fstab entry you gave remove executable permissions from *all* files in the partition (regardless of file type)?

Thanks again.
Yes. The way Linux handles NTFS all permissions are immutable.

NTFS has no Linux ownership and permissions bits which is why a chown or chmod has no affect. Linux handles this by using fuse to create a "view" that gives it the appearance that it does and those permissions are set when the partition is mounted. Unless something is done to alter it an NTFS partition will mount with every single folder and file having permissions of 777: read/write/execute for owner, group, and others. To alter those permissions you use the umask / dmask / fmask operators. In all cases:

1 = removes execute
2 = removes write
4 = removes read

And they are additive so a 7 ( 1+2+4 ) removes all permissions.

For a folder you need the execute bit enabled or you won't be able to open it which is why I made dmask ( directory mask ) 000 above - it will remove nothing. But for files an fmask ( file mask ) of 111 will remove the execute bit:

777 - default file permissions
111 - fmask
===
666 - Read / Write but no Execute for all files.

Re: <SOLVED> Removing executable permissions from text file on NTFS partition

Posted: Fri Apr 07, 2017 10:12 am
by chellrose
That's neat, thanks for the info! I'll add this to my Linux "toolkit".

Re: Removing executable permissions from text file on NTFS partition

Posted: Sat Mar 02, 2019 8:42 am
by bradrar
altair4 wrote:
Sat Apr 01, 2017 4:49 pm


Or Change the behaviour of Nemo:
Nemo > Edit > Preferences > Behavior > Executable Text Files > View executable text files when they are opened

Thank you. I am having the same problem. this solves it

Re: Removing executable permissions from text file on NTFS partition

Posted: Fri Oct 11, 2019 2:49 pm
by sobuj53
altair4 wrote:
Sat Apr 01, 2017 4:49 pm
Change the behaviour of Nemo:
Nemo > Edit > Preferences > Behavior > Executable Text Files > View executable text files when they are opened
Thank you. This solved my problem too :D