CHMOD

From DreamHost
Jump to: navigation, search

CHMOD is a command for controlling Unix File Permissions. It lets you tell the system how much (or little) access it should permit to a file. All of your files and directories have a number of attributes that are set when they are created. To display the attributes of each file and directory in the working directory use the "ls -la" command in your shell account. Here is an example listing:

 

[user@linux sites]$ ls -la
drwxr-xr-x  16 root  root  1024 Oct 20 19:56 .
drwxr-xr-x   9 root  root  1024 Sep  5 22:56 ..
drwxr-xr-x   9 foo   user  1024 Sep  5 22:56 dir1
drwxr-xr-x   9 foo   user  1024 Sep  5 22:56 dir2
drwxr-xr-x   9 foo   user  1024 Sep  5 22:56 dir3
-rw-r--r--   9 foo   user  1024 Sep  5 22:56 file1
-rw-r--r--   9 foo   user  1024 Sep  5 22:56 file2
-rw-r--r--   9 foo   user  1024 Sep  5 22:56 file3

 

To the far left of each file or directory name there are ten characters which show the attributes. The first column indicates whether the entry is a directory (d) or not (-). The other nine characters are organized into three groups of the three.

(drwxr-xr-x) The first group pertains to the owner (that would be you for your files).

(drwxr-xr-x) The second group pertains to people in your group.

(drwxr-xr-x) The third group pertains to everyone else.

Within each group of three are three characters. The first indicates read (r) permission. The second indicates write (w) permission. The third indicates execute (x) permission. If the permission is not present, a ``- will replace the r, w, or x.

To perform a chmod change on a file you can either do it through your shell account or through an FTP client.


Shell



chmod mode filename

 

where mode is a three digit octal number. The first digit pertains to the owners privileges. The second pertains to the groups privileges, and the third pertains to everyone else's privileges. Each octal digit is composed of the addition of three components. The read component is worth 4, the write component worth 2, and the execute component worth 1. Suppose I wanted the owner to have read, write, and execute privileges, the group to have read and write privileges, and everyone else to have read privileges only. The octal number I would use with chmod would be 764.

See Also


External Links