Why wouldn't one just use chmod 777?

I am looking for more information about Unix based systems, and there was a link:

Permissions in Unix on Mac

about using permissions on Unix on the Mac.

The basic chmod command goes:  $ chmod ### directory/filename

Why wouldn't one just put:

$ chmod 777 directory/filename

Wouldn't that allow

  • drwx------ : directory accessible only by owner
  • drwxr-xr-x : directory anyone can access
  • -rwxr-xr-x : file anyone can read and execute
  • -rw-r----- : file only people in the group can read

to be

drwxrwxrwx : directory anyone could access?

2

1 Answer

There's nothing inherently dangerous about using

$ chmod 777 directory/filename

but you need to be careful/selective as to which files/directories you apply it to.

This is because it makes all users able to read, write, and execute and this can be dangerous. This applies to your user profile, other users on that computer/OS, and possibly hackers from outside your machine that have breached it. If anyone other user got into your system that was unauthorized, they could view the data within, delete the file altogether, execute it for some malicious gain, etc.

That being said, there are other ways to set permissions with chmod that don't give quite as much freedom and you should make use of these other methods to give the least permission to any file as possible. But when you use the above command, this is giving the directory/filename the most possible permission.

For example, use$ chmod u+x filenameif you wanted to give permissions to just the user for just this file. For more beginner examples, see here.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like