Ubuntu – Does ubuntu treat downloaded files specially

14.04command linepermissions

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

Best Answer

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.

Related Question