1

I wanted to install certain software. The package had lots of files including some shell scripting files. Initially I had to select some files and then make it executable:

chmod 777 shellscr1

but then I realized that there are many such files which I will have to make executable. So as a shortcut, I did this:

chmod 777 *

and now all the files are executable.

Are there any serious consequences of doing this (apart from security)?

4 Answers 4

4

Depending on the program, it could have no negative affects or it could make the software unusable.

For example, change the permissions of your ~/.ssh directory and see what error you get when you try and ssh into another machine.

Some programs access config files as a specific user. with 777 permissions, anyone could overwrite the file making them the file owner.

3

As pointed out by others, there's no reason (at least not presented in the question) why the files would need to be world-writeable. Something like chmod 755 * or chmod +x * should suffice.

However I will narrow down the answer even more and give you an answer that does exactly what you're asking for. A shell script is always expected to begin with a shebang such as

#!/usr/bin/env bash

So here is a snippet that will search for any files in the current directory starting with the characters #!/ and make those executable. In other word, this command will only mark those files that look like shell scripts as executable.

for file in *; do [ "$(head -c 3 "$file")" = '#!/' ] && chmod +x "$file"; done;
2

Apart from security there aren't any serious consequences. (speaking logically of course)

0

Initially I had to select some files and then make it executable:

 chmod 777 shellscr1

Making them executable does not mean 777, it means 755. You may at least change this, for obvious reasons connected to security.

Making shell scripts executable may occasionally have some some adverse effects. For instance, if your /bin/sh points to a different shell than the one the script is intended for, you may make it essentially unusable. A good programmer would have taken steps to prevent that, and by changing permissions you may have voided his efforts.

But, I repeat, this applies only if your /bin/sh points to a non-standard shell.

1
  • That answer is going to confuse the Hell out of people. It gives the erroneous impression that there's one standard /bin/sh and a lot of non-standard /bin/shs. It also gives the wrong impression that someone nowadays using #!/bin/sh is intending a specific shell, a notion that went away in the 1980s-1990s when (POSIX) operating systems that didn't and couldn't have the non-free Bourne shell came about. There's a way of reading that answer as written such that it's right, but it's not the way that people who don't already know the right answer are going to read it.
    – JdeBP
    Jan 18, 2014 at 11:19

You must log in to answer this question.

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