wiki:faq/files/chmod

Version 5 (modified by Dana, 6 years ago) (diff)

--

How do I know if a file is world readable? How can I change that?

On a typical Unix-style system, there are three sets of permissions:

  • user: the permissions for the person who owns the file
  • group: the permissions for users who are in the group associated with the file
  • other: the permissions for everyone else who has an account on the server

Each set of permission can have three values:

  • write access
  • read access
  • execute access

The first two are self-explanatory. The third (execute access) has two different meanings:

  • For a directory, it means that you can enter the directory and get details of the files in the directory
  • For a file, it means you can execute the file (required if the file is a program)

If you are using an SFTP program to access your directories, the method for will vary depending on the program you are using. If you are using WinSCP, simply right click on the file or folder and click properties. You will see the current permissions and be given an opportunity to change them.

If you are using secure shell (ssh) you can change the mode of a file or directory with the chmod command. In the following examples, the change in mode is being applied to the directory or file named foo.

# remove read access from others
chmod o-r foo

# remove read access from the group
chmod g-r foo

# remove read and execute from all users except the owner
chmod go-rx foo

# remove all permissions from anyone but the owner
chmod go-rwx foo

# Add read and execute access for everyone
chmod a+rx foo

If you want to learn more: