[SOLVED] Txt files copied from macOS are executable, why\?
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
[SOLVED] Txt files copied from macOS are executable, why\?
My macbook pro mid-2012 13-inch computer died recently.
I moved over all my files in the "Documents" folder from the home directory of my Mac OSX over to my Documents directory in Linux Mint.
All my text files kept getting that prompt to open them as executables! Grrrr
Guess moving .txt files over from Mac OSX to Linux Mint causes Linux Mint to treat them as executables. Thankfully right-clicking and deselecting the checkbox in the permissions tab for "allow executing file as program" was all I needed to do.
Thanks all for explaining this to everyone on the internet!
Now the real question to ask is why .txt files created in Mac OSX wind up becoming treated as executables on Linux Mint.
I moved over all my files in the "Documents" folder from the home directory of my Mac OSX over to my Documents directory in Linux Mint.
All my text files kept getting that prompt to open them as executables! Grrrr
Guess moving .txt files over from Mac OSX to Linux Mint causes Linux Mint to treat them as executables. Thankfully right-clicking and deselecting the checkbox in the permissions tab for "allow executing file as program" was all I needed to do.
Thanks all for explaining this to everyone on the internet!
Now the real question to ask is why .txt files created in Mac OSX wind up becoming treated as executables on Linux Mint.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: Txt files copied from macOS are executable, why\?
Probably — same as for NTFS partitions — if you on the fly mounted the HFS+ partition in Linux Mint, without specifying options, same default permissions were used for all files on the partition and that means all text files would also have been marked as executable. But also every other file you copied from there. Do a check on that. If you copied any documents or images for example, give them a right-click and check on Properties > Permissions if they are marked as executable?
Using non-Linux filesystems with Linux can work fine but usually requires fine-tuning mount options to prevent all files from being made executable — they are made executable because of the incompatible filesystem which implements file permissions in a different way so to let you execute files on that filesystem it just assumes all files are executable. A usual mount option is to make none of the files executable.
Anyway. If you have the copied files in directories where there should be no executable files, it is possible to remove these permissions in one go. In your file manager browse to the directory where you have the files. Right-click an empty spot in the directory and from the context menu select "Open in Terminal". Confirm you're in the right directory (the directory is noted in the prompt; or type
pwd
command to see the full path of the current directory). Then run this command:find . -type f -exec chmod -x -c {} \;
That finds all the files in the current directory and subdirectories, and removes the execute permission from each. It prints what it does for each file changed. You can first run
find . -type f
to see the list of files it will process.Re: Txt files copied from macOS are executable, why\?
Forgot to mention that I had transferred my documents from Mac OSX to Linux Min using an NTFS drive. So the drive being partitioned as NTFS could have had something to do with that too.xenopeek wrote: ⤴Tue Jul 20, 2021 1:03 amProbably — same as for NTFS partitions — if you on the fly mounted the HFS+ partition in Linux Mint, without specifying options, same default permissions were used for all files on the partition and that means all text files would also have been marked as executable. But also every other file you copied from there. Do a check on that. If you copied any documents or images for example, give them a right-click and check on Properties > Permissions if they are marked as executable?
Using non-Linux filesystems with Linux can work fine but usually requires fine-tuning mount options to prevent all files from being made executable — they are made executable because of the incompatible filesystem which implements file permissions in a different way so to let you execute files on that filesystem it just assumes all files are executable. A usual mount option is to make none of the files executable.
Anyway. If you have the copied files in directories where there should be no executable files, it is possible to remove these permissions in one go. In your file manager browse to the directory where you have the files. Right-click an empty spot in the directory and from the context menu select "Open in Terminal". Confirm you're in the right directory (the directory is noted in the prompt; or typepwd
command to see the full path of the current directory). Then run this command:
find . -type f -exec chmod -x -c {} \;
That finds all the files in the current directory and subdirectories, and removes the execute permission from each. It prints what it does for each file changed. You can first runfind . -type f
to see the list of files it will process.
Re: Txt files copied from macOS are executable, why\?
Very cool! I will try out those two commands you suggested to remove the executable status of my simple text files inherited from my macbook pro.
Did you split off my question from the original thread? What was the URL for the original thread so I have it for reference? Want to read more about the interaction between NTFS drives and Linux.
Thank you!
Re: Txt files copied from macOS are executable, why\?
Yes. As per our forum rules, don't add new questions to solved topics and don't revive topics older than 6 months. The topic you replied to was both.
The logs don't show from which topic it was split but I think I found it in my browser history:
viewtopic.php?t=271125
Re: Txt files copied from macOS are executable, why\?
Ok, thanks for explaining that. Guess it's easier to find answers in threads about a single topic.xenopeek wrote: ⤴Tue Jul 20, 2021 4:17 pmYes. As per our forum rules, don't add new questions to solved topics and don't revive topics older than 6 months. The topic you replied to was both.
The logs don't show from which topic it was split but I think I found it in my browser history:
viewtopic.php?t=271125
Re: Txt files copied from macOS are executable, why\?
All files in NTFS in Linux are treated as with a mode of
The downside is, of course, that Windows can't read Linux filesystems, at least not natively; unless that has been somehow addressed, perhaps with WSL. I imagine most people just put regular, non-sensitive data on NTFS drives, and keep the rest on a Linux FS. I have some films on a couple of NTFS drives, but everything else is EXT4.
777
, which is rwxrwxrwx
in its symbolic form, meaning everyone has read, write, and execute rights to that file; this is probably the primary reason why people like me will generally recommend that you use a Linux filesystem, such as the Extension variants (IE: EXT4).The downside is, of course, that Windows can't read Linux filesystems, at least not natively; unless that has been somehow addressed, perhaps with WSL. I imagine most people just put regular, non-sensitive data on NTFS drives, and keep the rest on a Linux FS. I have some films on a couple of NTFS drives, but everything else is EXT4.
Last edited by Termy on Thu Aug 05, 2021 8:17 am, edited 1 time in total.
I'm also Terminalforlife on GitHub.
Re: Txt files copied from macOS are executable, why\?
Note though that is in essence easily adjusted through mount options; a problem is that the automounter makes it non-trivial to in fact specify mount options but for /etc/fstab mounts it's easily done. I.e., for a permanently mounted NTFS partitions you can for example have something like
Code: Select all
UUID=12345678-1234 /windows/c ntfs-3g uid=myusername,fmask=133,dmask=022
For non-permanent, automounted filesystems you can moreover have e.g. similarly
Code: Select all
UUID=12345678-1234 /mnt/usbstick ntfs-3g noauto,uid=myusername,fmask=133,dmask=022
Re: Txt files copied from macOS are executable, why\?
Nice. I always thought it was a hard limit, but it's nice to know there are mount options to set a given mode for files in NTFS. It's a shame you have to do it via '/etc/fstab' or when manually mounting the FS, though. Still, it's not bad for a FS not native to Linux. I noticed some interesting and disconcerting things, when I recently enabled NTFS support in the kernel:
- The kernel seems to only have so-called "experimental" write support for NTFS.
- The kernel documentation points out that writing in NTFS in Linux can cause data loss.
- You can compile the kernel with only read support for NTFS, which I've done.
I'm also Terminalforlife on GitHub.
Re: Txt files copied from macOS are executable, why\?
The (current; a new kernelspace NTFS driver from Paragon is about to get merged) kernelspace NTFS driver is not much use indeed but that's also the reason it's not in fact being used. NTFS-3G is a FUSE driver, i.e., operates fully in userspace and on specifically Ubuntu/Mint the type "ntfs" has in fact for some time now been an alias for "ntfs-3g" (in the sense that mount.ntfs for example is a link to mount.ntfs-3g). That's to say you could've in fact compiled the kernel without support for NTFS, period.
I believe the new Paragon kernelspace driver will be referred to as "ntfs3" just so as to not confuse the matter even further...
I believe the new Paragon kernelspace driver will be referred to as "ntfs3" just so as to not confuse the matter even further...
Re: Txt files copied from macOS are executable, why\?
You're quite right! I had no idea. Thanks for the awesome tip. I'll recompile the kernel without NTFS support and just use the 'ntfs-3g' package. Gold star to you.
I'm also Terminalforlife on GitHub.
Re: Txt files copied from macOS are executable, why\?
That was a spendid treat to watch that terminal command crunch through all the text files so quickly!xenopeek wrote: ⤴Tue Jul 20, 2021 1:03 amProbably — same as for NTFS partitions — if you on the fly mounted the HFS+ partition in Linux Mint, without specifying options, same default permissions were used for all files on the partition and that means all text files would also have been marked as executable. But also every other file you copied from there. Do a check on that. If you copied any documents or images for example, give them a right-click and check on Properties > Permissions if they are marked as executable?
Using non-Linux filesystems with Linux can work fine but usually requires fine-tuning mount options to prevent all files from being made executable — they are made executable because of the incompatible filesystem which implements file permissions in a different way so to let you execute files on that filesystem it just assumes all files are executable. A usual mount option is to make none of the files executable.
Anyway. If you have the copied files in directories where there should be no executable files, it is possible to remove these permissions in one go. In your file manager browse to the directory where you have the files. Right-click an empty spot in the directory and from the context menu select "Open in Terminal". Confirm you're in the right directory (the directory is noted in the prompt; or typepwd
command to see the full path of the current directory). Then run this command:
find . -type f -exec chmod -x -c {} \;
That finds all the files in the current directory and subdirectories, and removes the execute permission from each. It prints what it does for each file changed. You can first runfind . -type f
to see the list of files it will process.
Thank you very much for sharing that command! I have built up a mental library of a few terminal commands over the years, but esoteric-looking stuff you provided certainly did the trick!
I really ought to pay for a live tutorial class on using Linux terminal like a pro. It's so nice not to have to do things one a time manually...
Yes, you're definitely right. I'll stick with free software file systems and avoid proprietary ones like NTFS, APFS, HFS+ etc. going forward. Linux is designed to be interoperable. Windows and Mac OSX are designed to keep you in their walled gardens. No thank you!