As provided by John, Drupal.org has an entire page on permissions.
With ls -alh
you will see the user and filepermissions that are used. If that gives access denied, or too little information, run ls -alh as root: sudo ls -ahl
. You should see something like:
drwxrwx--- 7 www-data greg 4096 2008-01-18 11:02 files/
drwxr-x--- 32 greg www-data 4096 2008-01-18 11:48 modules/
-rw-r----- 1 greg www-data 873 2007-11-13 15:35 index.php
The first column will, in your situation look like drwxrwxdrwx, a more readable version of 777.
The next two columns are more important: they should contain the user under which the apache server runs. On Ubuntu and Debian that is www-data, under CenOS/Redhat that is apache. Other unices may have other usernames.
Then simply change the ownership of the files directory and all files underneath it.
chown -R www-data:www-data files/
This will recursively (-R) change group and user ownership to apache of files/ and its content.
From there you can change the permissions to something safer:
sudo find . -type d -exec chmod u=rwx,g=rx,o= {} \; #change permissions on directories (-d)
sudo find . -type f -exec chmod u=rw,g=r,o= {} \; #change permissions on files (-f)
x
for directories means accessing and scanning it. x
for files meens executable. You don't want your images to be "executable" :)