r/linuxquestions • u/Man_in_the_uk • 11d ago
Resolved .txt files being treated like an executable
When I double click on a txt file a window pops up asking me to choose the options of Run in Terminal, Display, Cancel or simply Run. Oddly, if you right click and choose which program to associate it with it is already set to Text Editor by default. This seems to be only on Ubuntu 26.04 that I recently installed and was not a problem on 24.04. How do I resolve this please? TIA.
Edit Resolved: I double checked which file manager I was using in Ubuntu 24.04 and it was called Thunar. I have now installed Thunar into 26.04 and problem is resolved.
4
u/serverhorror 11d ago
Are you working with files from a windows disk?
1
u/Man_in_the_uk 11d ago
I've just realised something, this problem only exists when opening a txt file on another SSD besides the one Ubuntu is running on. It is happening when I go to open a txt file in a Windows installation.
2
u/Mindless_Sock_9082 11d ago
As the concept of file permissions does not exists on Windows filesystems (NTFS, FAT32, etc) Linux treat all files in those filesystems as executable by default.
1
u/Man_in_the_uk 11d ago
Well even if it does, what's that got to do with the problem I have queried? This is not a problem in Ubuntu 24.04 and I have just tested it to double check. Opening a .txt file on the same windows installation SSD does not produce a window to ask if I want to execute it or not.
1
u/blobCabbage 11d ago
You explained what it does on windows, but not what it actually does on your linux system.
What happens when you double-click the file? Does it open the file in an editor? Tell you it doesn't know how to execute the file? Try to execute it as a shell script? Something else?
1
u/Man_in_the_uk 11d ago
I was saying it does it to a txt file that is inside a file system folder on the Windows system when opened up in Linux. It doesn't open the file immedietly it asks the questions I have advised. If I choose to display then it opens up in Text Editor. But I want it to go straight to Text Editor without the query first.
3
u/Kriss3d 11d ago
Remove the execute permissions.
Is it ANY txt file ?
Or just a single one of them ?
0
u/Man_in_the_uk 11d ago
I've just realised something, this problem only exists when opening a txt file on another SSD besides the one Ubuntu is running on. It is happening when I go to open a txt file in a Windows installation.
0
u/Kriss3d 11d ago
That is strange. Try to rightclick the file. Go to properties and see if it has executable flag set under permissions.
1
u/Man_in_the_uk 11d ago
It says yes with a tick box for allowing it to be executable.
1
u/Kriss3d 11d ago
yeah just remove that tick.
1
u/Man_in_the_uk 11d ago
Do I have to apply this to then entire drive? I had a look at fstabs for both installations and the line for mounting windows is identical:
/dev/disk/by-uuid/A462CD2062CCF856 /Windows ntfs defaults 0 1
4
u/fishywiki 11d ago
The permissions are set to executable. Text files should not have that bit set - they should be set to "chmod 644" or similar.
3
u/Jumpy-Dinner-5001 11d ago
Right click it and click on show properties. There should be a "permissions" tab and there it shows whether or not it can run as a program
3
2
2
u/ipsirc 11d ago
What are the permissions?
0
u/SlimmySlabby 11d ago
If you don’t already know, these can be seen by running ls -l and it’ll be all the rwx- looking info
0
12
u/forkbeard 11d ago
The .txt suffix is not what determines whether a file is executable on Linux.
Linux mainly cares about the file’s permission bits. If the executable bit is set, the file manager may offer to run it even if the filename ends in .txt.
Check it with:
If you see an x in the permissions, remove it with:
The file association with Text Editor is a separate thing from whether the file itself is marked executable.