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

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
User avatar
chellrose
Level 1
Level 1
Posts: 22
Joined: Sat Mar 25, 2017 11:04 am

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

Post 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.
Last edited by chellrose on Sat Apr 01, 2017 10:13 pm, edited 1 time in total.

altair4
Level 19
Level 19
Posts: 9993
Joined: Tue Feb 03, 2009 10:27 am

Re: Removing executable permissions from text file on NTFS partition

Post 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.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

User avatar
chellrose
Level 1
Level 1
Posts: 22
Joined: Sat Mar 25, 2017 11:04 am

Re: Removing executable permissions from text file on NTFS partition

Post 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.

altair4
Level 19
Level 19
Posts: 9993
Joined: Tue Feb 03, 2009 10:27 am

Re: Removing executable permissions from text file on NTFS partition

Post 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.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

User avatar
chellrose
Level 1
Level 1
Posts: 22
Joined: Sat Mar 25, 2017 11:04 am

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

Post by chellrose »

That's neat, thanks for the info! I'll add this to my Linux "toolkit".

bradrar
Level 2
Level 2
Posts: 54
Joined: Sun Aug 19, 2018 2:48 am

Re: Removing executable permissions from text file on NTFS partition

Post 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

sobuj53
Level 1
Level 1
Posts: 10
Joined: Fri Oct 04, 2019 12:33 am

Re: Removing executable permissions from text file on NTFS partition

Post 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
First deserve then desire.

Post Reply

Return to “Software & Applications”