There are three groups of permissions for each file and directory:
| ||||||
-rwxrwxrwx 1 avery users 2525 Feb 18 09:17 index.html
^\ /\ /\ /
| V V V
| | | `-- others (non Panixians)
| | `-- group (doesn't apply)
| `-- user (authorized FTP user)
`-- d=directory, -=file, l=link, etc
The list of letters at the far left is the permissions table. The first letter indicates what the file is (plain file, directory, link, etc.). The second, third, and fourth letters are read, write, and excecute for the file's owner. The next three letters are the permissions for the file's group, and the last three letters are the permissions for others.
| [panix-avery] <~/corp-ftp> ftp_chmod ftp.domain.com 704 foo.txt | ('704' is the permissions number.) |
These numbers represent the three user types. The first number on the left side ( the '7' in the example above) is for "user", the middle one (the '0') is for "group" (which is completely unused in the context of FTP, and should always be set to no access), and the right hand one (the '4') is for "other." Now, here's what each number does:
0 = --- = no access 1 = --x = execute 2 = -w- = write 3 = -wx = write and execute 4 = r-- = read 5 = r-x = read and execute 6 = rw- = read and write 7 = rwx = read write execute (full access)
So, if you set a file to:
ftp_chmod ftp.domain.com 604 foo
^^^
||`-- others have read access
|`-- group has no access (they don't matter)
`-- user has read and write access
This would be a good permission set for a file you wanted an authorized user to be able to download or delete,
while only allowing anonymous users to download
the file.
For example, typing ftp_chmod ftp.domain.com go+r foo, turns on the read bits for group and others on file "foo". Note, that this command does NOT reset the other bits, so any previously specified permissions will not be changed. For example, this did not change any permissions for user and if group already had execuete permissions, it did not remove it.
But, if you type ftp_chmod ftp.domain.com go=r foo, it will set file foo to be readable by group and other and turn off any write and execute permissions group and others had.
Now, whether you use the numbers or the text, you can name files using standard wild cards. For example, ftp_chmod ftp.domain.com 604 *.html will change the permissions on all your .html files, while ftp_chmod ftp.domain.com 604 foo* will change permissions on all files and directories with names starting with foo.
You should determine what access you want to give the file owner, and what access you want to give anonymous users. Look up the octal number on the chart below for each, and put them together with a zero (for the unused group permissions) between them. Plug that number into the command:
ftp_chown ftp.<domain.com> <octal-number>
<file>
Replace <domain.com> with your domain,
<octal-number> with the octal number you look up in
the table below, and <file> with the file or
directory you want to set permissions for.
First, you must set permissions for the directory in which files are contained, because that governs what a user may do to any file in the directory:
| What a user can do: | Permission needed: | Octal-Number: |
|---|---|---|
| closed to all access | --- | 0 |
| files downloadable only if filename is known | --x | 1 |
| files listable and downloadable | r-x | 5 |
| files listable, downloadable, uploadable, and deletable | rwx | 7 |
ftp_chmod ftp.domain.com 701 directory ), FTP users
will be unable to list the files in the directory, but will be
able to download files if they know the name of the file they want.
This may be useful to you if you want a medium amount of security on a
directory, but wish to make files in the directory available to people
to whom you don't want to give an FTP account.
After you've set the permissions for a directory, set the permissisons for the files in the directory:
| What a user can do: | Permission needed: | Octal-Number: |
|---|---|---|
| inaccessible to all | --- | 0 |
| downloadable only | r-- | 4 |
| downloadable and deletable | rw- | 6 |
For more information on the chmod and ls commands, check out the Unix Manual Pages. You'll find them by going to a Unix prompt and typing man chmod or man ls.
[panix-slavery] 17 Oct <~/corp-ftp> What?! ls -l total 4 dr-xr-xr-x 2 slavery 512 Oct 17 16:41 bin drwxr-xr-x 2 slavery 512 Oct 17 16:41 etc drwx---r-x 2 slavery 512 Oct 17 16:41 pub -rw-r--r-- 1 slavery 57 Oct 17 16:41 welcome.msg |
The second collumn shows you the file owner In this case, all of the files are owned by user slavery.