Understanding executable file setting

Here a simple problem to solve. I read up on this, tried the chmod command several times, and then went and found some samples of it use but something is still not connecting with me.
My problem / question;
I want to set a file permission so that Linux will not think it is an executable file. When I go to edit a file, I get this message.
Screenshot from 2020-08-16 16-16-42
When I do a ls -l on the file it looks like this;
-rw-r–r-- 1 easyt50 easyt50 1252 May 17 23:55 East_to_West.txt
The ‘x’ for execute is not set as you can see. This problem is from almost all files that came from windows. If I create a new file in Linux, the execute flag is not set.
easyt50@X220:~/test$ ls -l
total 4
-rw-rw-r-- 1 easyt50 easyt50 21 Aug 16 16:10 t-file.txt

2 Likes

What’s the output of

head -1 East_to_West.txt

?

1 Like

As requested @Akito

Z_Misc$ head -1 East_to_West.txt
How far east, west, north and south have I been

1 Like

what about file East_to_West.txt?

I’m sorry @01101111, I don’t understand the question.

no need to apologize :slight_smile: i could have written that more clearly. what is the output of the command:

file East_to_West.txt

?

Oh, file was the command, I read it as ‘the file’.
As requested;
Z_Misc$ file East_to_West.txt
East_to_West.txt: ASCII text, with CRLF line terminators

if you right-click on the file and look at the properties, is there a field labeled “open with” or something similar? if so, what is it set to for .txt files?

Is this what you were thinking of?

1 Like

next tab to the right: “Open With”.

I hope this helps.

text editor is what i would expect, but was thinking it might have gotten set to something different. if you change that to LibreOffice Writer, do you still get the same question about executing it when you try to open it? also, do you get the question about executing it when you double-click on the file name or icon?

1 Like

Hello Howard,

Could you please check the preference of the file manager? Perhaps it is set to “Ask everytime”?

1 Like

my 19.3 vm is set to “ask everytime”, but xed opens a test file every time. that file is just “ascii text” though. i am wondering if for whatever reason

is being misinterpreted as executable. i haven’t worked with any windows text files in a while.

1 Like

Try:

sudo apt install -y dos2unix
dos2unix East_to_West.txt

And then try to open again.

1 Like

@01101111, if I right click and open with LibreOffice then no pop up screen asking the question and it goes straight to edit. It’s strange, but if I right click and open with text editor, again no question. :thinking:

That’s because the “Open with…” option is already final. It cannot ask after you already decided how to open it.

1 Like

@abhishek, you are right! It is set to “Ask everytime”. Changing it to “View executable text files when they are open” seems to be a great work around / solution. Tho it does not explain why a text file from Windows vs a text file from Linux are treated differently. I do not get the pop up screen from text files created in Linux leaving the editor option unchanged.

dos2unix was my next thought as well.

1 Like

Hi @Akito, as requexted;
$ dos2unix East_to_West.txt
dos2unix: converting file East_to_West.txt to Unix format…

Did not stop the pop up screen. :confused:
I was hoping I could convert the files.

PS. Somehow I did it wrong the first time. Copying the file to /Home and doing the test again and it worked!

1 Like