Ubuntu: Changing permissions for /var/www/html



Question:

I've studied this topic https://help.ubuntu.com/community/FilePermissions for a while and can't get it work for some reason.

Particularly, these lines interest me the most:

To change all the permissions of each file and folder under a specified directory at once, use sudo chmod with -R

$ sudo chmod 777 -R /path/to/someDirectory  $ ls -l  total 3  -rwxrwxrwx  1 user user 0 Nov 19 20:13 file1  drwxrwxrwx  2 user user 4096 Nov 19 20:13 folder  -rwxrwxrwx  1 user user 0 Nov 19 20:13 file2  

Here's what I typed:

mark@ubuntuserver:~$ sudo chmod 755 /var/www/html  mark@ubuntuserver:~$ ls -l  total 0  

Then I checked any changes in sftp:

sftp> cd /  sftp> cd var/www/html  sftp> pwd  Remote working directory: /var/www/html  sftp> ls -l  -rw-r--r--    1 root     root        11321 Apr 10 20:07 index.html  

From the output it's clear that the html directory is still modifiable only by root.

How can I change this in the way that me (non-root) can upload files to the html directory ?

I also tested:

A file's owner can be changed using the chown command. For example, to change the foobar file's owner to tux:

$ sudo chown tux foobar  

I typed from the server:

sudo chown mark owner  

no effect.


Solution:1

In this case I would leave the directory ownership alone. To modify the permissions for that specific directory so that you can write to it, set read/write permissions, the command being sudo chmod 766 -R /var/www/html. This will assign full permissions 7 for the owner, read/write 6 for the group, and read/write for everyone 6, recursively.


Solution:2

You can make yourself the owner of that directory

sudo chown pi /var/www/html  

But you definitely want to set the permissions

chmod 766 -R /var/www/html  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »