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.
sudo chown mark ownerwhat is that suppose to do? How come you introduce a file or dir called "owner" there? – Rinzwind Apr 14 '17 at 19:33sudo chown user:user mydocswhere the new owner and group isuserand the directory you are taking ownership of ismydocs– Gansheim Apr 14 '17 at 19:35sudo chmod 766 -r /var/www/html– Gansheim Apr 14 '17 at 19:37ls -lcommand from their home directory. @Mark Unless you are in the directory that you are trying to view/manipulate, you need to specify the path, in this case you should have issued the command asls -l /var/www/html– Gansheim Apr 14 '17 at 19:40sudo chown mark /var/www/html/is this correct ? Because I checked and it's still owned by a root. Yes, I used the commandls -lin the html directory to avoid any silly mistakes. – Mark Alexa Apr 14 '17 at 19:43chmodchanges permissions,chownchanges owner. 755 first digit (7) means that 'owner' has all permissions, while second and last digits (5) mean that 'group' and 'other' both have read and execute permissions. You could add your user to the group and give full permissions to group too so that you don't have to make that many changes. – Samuel Apr 14 '17 at 19:45sudo chmod 766 -r /var/www/htmlseems like a wrong syntax. It says >chmod: cannot access '766': No such file or directory> it treats 766 not as a permission rule but as a target directory. – Mark Alexa Apr 14 '17 at 19:47sudo chmod 766 -R /var/www/htmlsorry bout that – Gansheim Apr 14 '17 at 19:52sudo chmod 766 -r /var/www/htmlas an answer so I can nike it ? I just needed to put upper case at R and it worked ! I tried to upload the test file and it's there ! Post it ! – Mark Alexa Apr 14 '17 at 19:52