The CHMOD Command
When working with files under Unix, it is possible to change the file permissions on them. Changing file permissions can dramatically increase the usefulness of the system for you in a variety of ways. For example, it can help you enhance the security of your home directory by allowing access to a file to yourself only. Or it can facilitate communication among a group, by allowing you to set a file to be readable by everyone on the system.
When changing permissions you can work alphabetically or numerically. For the alphabetical listings the + and - signs toggle permissions on or off. The = sign sets the permissions outright. Putting nothing after it turns all the permissions for the specified people off. To alter a file using the alphabetical characters you would enter:
chmod [group specification] [+ or -] [directory/filename]
With the numerical settings you add them together until you have the result you want, and then type:
chmod [number] [directory/filename]
The tables to the right of this text illustrate the alphanumerics necessary to alter the file permissions. Usage examples can be found below. For a list of standard permissions, please see the Standard Permissions table below.
For examples of chmod in action, visit the File Permissions for Web Pages page.
|755||Used for directories and CGI files.|
|644||Used for regular HTML and image files.|
|chmod g+w [filename]||Add write access for the group.|
|chmod go-w+x [directory/executable filename]||Remove write access and allow execute access to the group and others.|
|chmod u=rwx,go= [filename]||Give the user all access and no access to the group and others.|
|chmod 644 [filename]||Read and write access to the user; read to the group and others.|
|chmod 664 [filename]||Read and write access to the user and group, read to others.|
|chmod 755 [directory/executable filename]||Read, write, and execute access for the user; read and execute for the group and others.|
|chmod 775 [directory/ executable filename]||Read, write, and execute for the user; read, write, execute for the group; read and execute for others.|
Last modified: Aug 22, 2011, 15:11 EDT