i'm hosting some websites in same server, but this server doesn't come with root login and password, i only have access to ubuntu user and password, and when i'm logged in, i can use the command sudo su -
to turn into a root user.
but using i'm using sftp to edit the files of the websites, and i can only log in using ubuntu user, i'm not able to use root user.
the problem is that i'm having permission denied when i try to edit some files.
the files must have permission 644
and the folders must have permission set to 755
if the permissions aren't like this my application doesn't run.
so i have to choose, between editing the files and stop the application, or run the application and get permission denied when i edit the files. i can't do both at the same time, it's boring.
so i gotta use this command to edit anything i want, and the application stops, because the permission of the files goes to 674
and permission of the folders goes to 775
:
sudo usermod -a -G ubuntu www-data
sudo setfacl -R -m u:ubuntu:rwx /var/www/
and when i edited everything i gotta use this command, to the permissions go back to 644
in files, and 755
in folders and the application goes back to normal.
find /var/www -type d -exec chmod 755 {} \;
find /var/www -type f -exec chmod 644 {} \;
so how can i fix this? i want to do both at the same time.
You are using the user
ubuntu
which doesn't have permission to create/edit files in /var/www. So you're giving it permissions, uploading the new files, and removing permissions. You need to remove permissions back because the server will give you permission denied if your files have too wide permissions.You have 3 alternatives:
FollowSymLinks
), but once it's set up all files will have proper permissions andubuntu
will be the owner.P.S.: you don't need to run the
usermod
command multiple times. Once the user is in the group, it's in the group, there shouldn't be any process removing it from the group.