1

There is a script which just adds extra lines to my /etc/hosts file to enable local development. Since it's pretty useful, I decided to keep it in a gist.

When one of my friends downloaded the shell-script, changed the necessary permissions and tried to run it, it failed.

The error shown is:

$ ./dev-mode

: No such file or directory

Even though the script runs perfectly file on my computer. The /etc/hosts file exists in both our computers, the permissions and the owners are the same. Every thing is absolutely similar.

Then he made a new file, copied the contents of the script to the new file, and changed the necessary permissions, and it RAN!

To my eyes, there is no conceivable difference between the two files, but a diff does that they are difference, but doesn't highlight any line or any character... Nothing. The permissions are same, etc.

Does ubuntu treat downloaded files somehow differently, and stop it from running?

Absolutely same files, one runs and the other doesn't

3
  • 1
    The diff could be explained, e.g., if the two files use a different character encoding. But why the first one doesn't run is hard to say without additional information. But generally, no, Ubuntu does not make any difference between a "downloaded" file and a "self-created" file. In fact, your whole Ubuntu system with all the files were downloaded when you first installed Ubuntu, and new files are downloaded with each update, and they are running fine ;) Sep 3, 2014 at 8:04
  • That error means that his terminal wasn't placed in the same directory in which he downloaded the file. If he downloads the file in the Desktop folder then he should first move to it cd ~/Desktop and then launch it ./dev-mode. Or he can use the full path $HOME/Desktop/dev-mode. To know the directory in which the terminal is placed there exists the useful command pwd.
    – dadexix86
    Sep 3, 2014 at 8:06
  • It would help if you shared the Gist with us and explained exactly what they ran (Bash's history can help).
    – Oli
    Sep 3, 2014 at 8:09

1 Answer 1

1

Essentially, yes. When you download a file from the Internet, you're grabbing the data which is inside the file.

What you're not getting is the permissions which are applied to the file. That's done on your local filesystem.

To make a file executable on your local system, drop into a terminal and run

chmod +x filename.sh

That tells your filesystem to treat that particular file as executable.

There's a good reason for this. Suppose that you were to download a file which had permissions allowing anyone on your computer to run it. That's a clear security risk.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .