StevenOliver Posted August 6, 2020 Share Posted August 6, 2020 (edited) On Ubuntu 20.04, I've done this a hundred times and it's always worked fine:chown -R www-data:www-data /var/www/html usermod -aG www-data My_User_Name Today, when trying to write a file in html, I get a "Directory '.' is not writeable" error. All the directories are 755, all the files are 644, and I've verified I'm a member of www-data. What am I missing, please? Thank you. p.s. I know I can do "chown -R MyUserName:MyUserName /var/www/html" and then I can write to the directory... but I'm trying to figure out why on earth the above suddenly won't work. Edited August 6, 2020 by StevenOliver Quote Link to comment https://forums.phpfreaks.com/topic/311282-directory-not-writeable-even-though-chown-and-chmod/ Share on other sites More sharing options...
requinix Posted August 6, 2020 Share Posted August 6, 2020 Can you tell me what the permissions 755 mean? Quote Link to comment https://forums.phpfreaks.com/topic/311282-directory-not-writeable-even-though-chown-and-chmod/#findComment-1580393 Share on other sites More sharing options...
StevenOliver Posted August 6, 2020 Author Share Posted August 6, 2020 (edited) 755 means: Owner can read, write, execute. Everyone else can read, execute. When I stat my d and f:755 drwxr-xr-x www-data www-data Aug 5 20:18 www 755 drwxr-xr-x www-data www-data Aug 5 20:19 html 644 -rw-r--r-- www-data www-data Aug 1 18:12 index.html ... and check if I'm a member of www-data....$ groups //command lineMy_User_Name sudo www-data // result So, www-data owns the files. And, I'm a member of www-data. As a member of www-data, I should also be able to write. What am I missing? Edited August 6, 2020 by StevenOliver Quote Link to comment https://forums.phpfreaks.com/topic/311282-directory-not-writeable-even-though-chown-and-chmod/#findComment-1580404 Share on other sites More sharing options...
requinix Posted August 6, 2020 Share Posted August 6, 2020 7 hours ago, StevenOliver said: 755 means: Owner can read, write, execute. Everyone else can read, execute. That's right: owner can write, everybody else cannot. 7 hours ago, StevenOliver said: So, www-data owns the files. And, I'm a member of www-data. As a member of www-data, I should also be able to write. What am I missing? www-data is the owner. Are you www-data? Quote Link to comment https://forums.phpfreaks.com/topic/311282-directory-not-writeable-even-though-chown-and-chmod/#findComment-1580415 Share on other sites More sharing options...
StevenOliver Posted August 6, 2020 Author Share Posted August 6, 2020 But I am a member of the www-group. I thought that was the point of "becoming a member." Would you please explain what is the point of being a member of the www-data group if I do not inherit its privileges? Quote Link to comment https://forums.phpfreaks.com/topic/311282-directory-not-writeable-even-though-chown-and-chmod/#findComment-1580419 Share on other sites More sharing options...
requinix Posted August 6, 2020 Share Posted August 6, 2020 You did inherit the privileges of the www-data group. But the permissions you applied to allow writing are not for the www-data group. They are for the owner of the directory, and in this case the owner of the directory is www-data the user. There is a user named "www-data" and there is a user group named "www-data". They are two separate (but related) things. Quote Link to comment https://forums.phpfreaks.com/topic/311282-directory-not-writeable-even-though-chown-and-chmod/#findComment-1580420 Share on other sites More sharing options...
StevenOliver Posted August 7, 2020 Author Share Posted August 7, 2020 Unfortunately, I have google searched this exact thing, and found too many conflicting "solutions." Each "solution" proposes a line of code, followed by, "well, this worked for me...". And, I don't want to mislearn yet another "hack." Rather, I'd like to know the correct way to do this. So here is a properly worded question: For a sudo user to create files in the /var/www/html directory of an Apache2/Ubuntu 20.04 cofiguration, what are the "best practices" lines of chmod and chown code to accomplish this? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/311282-directory-not-writeable-even-though-chown-and-chmod/#findComment-1580421 Share on other sites More sharing options...
requinix Posted August 7, 2020 Share Posted August 7, 2020 A "sudo user" doesn't make sense. sudo is a tool that lets you run commands as another user - typically root. Forget for a moment what you are trying to do. Why are you trying to do it? What is fiddling with permissions supposed to solve? Quote Link to comment https://forums.phpfreaks.com/topic/311282-directory-not-writeable-even-though-chown-and-chmod/#findComment-1580422 Share on other sites More sharing options...
StevenOliver Posted August 7, 2020 Author Share Posted August 7, 2020 Forget it. Thank you for your time. Quote Link to comment https://forums.phpfreaks.com/topic/311282-directory-not-writeable-even-though-chown-and-chmod/#findComment-1580423 Share on other sites More sharing options...
requinix Posted August 7, 2020 Share Posted August 7, 2020 Next time try StackOverflow. They don't mind giving you the right answers to the wrong questions. Quote Link to comment https://forums.phpfreaks.com/topic/311282-directory-not-writeable-even-though-chown-and-chmod/#findComment-1580424 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.