A file's file mode bits determine who is able to read, write or execute a file.
Making a file read only
Removing the w
flag makes a file read only.
The following command removes the w
flag for everyone (a
= all)
chmod a-w readme.txt
The following command adds the w
flag for the file's owner (u
= user) so that at least the owner of the file can change it:
chmod u+w readme.txt
The following command removes the r
flag from others (o
) so that the «rest of the world» cannot read the file:
chmod o+w readme.txt
Changing files to 644, directories to 755
Uppercase X (+X
) set the executable bit for directories only.
chmod -R a=r,u+w,a+X /path/to/directory