When you encounter 777
or 666
permissions, ask yourself "Is there a better way to do this?" "Does everybody on the system need write access to this?" For example, if a script or program is set to 777
, then anyone on the system can make changes to that script or program. Since the execute bit is set for everyone, that program can then be executed by anyone on system. If malicious code was inserted either on purpose or on accident it could cause unnecessary trouble. If multiple people need write access to a file consider using groups and limiting the access of others. It is good practice to avoid using 777
and 666
permission modes.
Working with Groups
If you work on the sales team and each member needs to update the sales.report
file, you would set the group to sales
using the chgrp
command and then set the permissions to 664
(rw-rw-r--
). You could even use 660
(rw-rw---
) permissions if you want to make sure only members of the sales team can read the report. Technically 774
(rwxrwxr--
) or 770
(rwxrwx---
) permissions work also, but since sales.report
is not an executable program it makes more sense to use 664
(rw-rw-r--
) or 660
(rw-rw----
).