Protecting and Sharing Files
UNIX makes it easy for users to share files and directories. Controlling exactly who has access takes some explaining, though—more explaining than we can do here. So here’s a cookbook set of instructions. If you have critical security needs or you just want more information, see the references in Appendix A.
Directory Access Permissions
A directory’s access permissions help to control access to the files in it. These affect the overall ability to use files and subdirectories in the directory. (Once you have access to a directory, the ability to read or modify the contents of specific files is controlled by the file access permissions; see the second of the following two lists.)
In the commands below, replace dirname with the directory’s pathname. An easy way to change permissions on the working directory is by using its relative pathname, . (dot), as in "chmod 755 .“.
To keep yourself from accidentally removing files (or adding or renaming files) in a directory, use chmod 555 dirname. To do the same, but also deny other users any access, use chmod 500 dirname.
To protect the files in a directory and all its subdirectories from everyone else on your system—but still be able to do anything you want to dp there—use chmod 700 dirname.
To let other people on the system see what’s in a directory—and read or edit the files if the file permissions let them—but not rename, remove, or add files—use chmod 755 dirname.
To let people in your UNIX group add, delete, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access