-2

Whats different "name.txt" vs "name.txt " in Linux?

If I rename name.bin to name.txt - is normal and file doesn't executable.

If I rename name.bin to file.txt (with space after filename) - file will be executable.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
69 420 1970
  • 375
  • 3
  • 17
  • 2
    Please prove that assertion, as it is a bit difficult to believe. – RudiC Oct 20 '18 at 15:41
  • what did you use to "rename" `name.bin` to `file.txt\ `? if you use `cp name.bin file.txt\ ` and `file.txt\ ` already exists and is executable, it will stay that way; `cp` without the `-p` flag won't change its permissions. –  Oct 20 '18 at 15:42
  • Perhaps you're failing to invoke the correct filename? Demonstrate what you're doing so we can follow along. – Jeff Schaller Oct 20 '18 at 17:33
  • @ctrl-alt-delor https://attack.mitre.org/wiki/Technique/T1151 – 69 420 1970 Oct 20 '18 at 17:54
  • @interesting, but not a Linux thing, it is a file manager thing. So you are changing weather the file-manager attempts to execute it (not weather it is executable). A simpler solution is to prevent downloaders from setting the execute bit. – ctrl-alt-delor Oct 20 '18 at 17:59
  • @ctrl-alt-delor thanks a lot! just I bad speak English! – 69 420 1970 Oct 20 '18 at 18:01
  • @Ctrl-alt-delor it might be a GUI file manager thing though. I might try this out. – roaima Oct 20 '18 at 18:52
  • @roaima, yes that is what I said. – ctrl-alt-delor Oct 20 '18 at 19:22

1 Answers1

2

Whether the file is executable (or not) is a matter of permissions, not of the name.

Use chmod a+x to make it executable and chmod a-x to disallow it. Full details here:

https://unix.stackexchange.com/a/297014/255708

ctrl-alt-delor
  • 27,473
  • 9
  • 58
  • 102
Frenzie
  • 106
  • 1
  • 2