How to keep the user “www-data” when modify file logged in as root?
up vote
0
down vote
favorite
I gave permission to the user "www-data" in the entire contents of the "/var/www" folder.
However, I work with the root user with a private key via SFTP, and whenever I modify a file, the owner of the file becomes root.
How to edit the files and keep the "www-data" as owner?
linux nginx sftp
New contributor
add a comment |
up vote
0
down vote
favorite
I gave permission to the user "www-data" in the entire contents of the "/var/www" folder.
However, I work with the root user with a private key via SFTP, and whenever I modify a file, the owner of the file becomes root.
How to edit the files and keep the "www-data" as owner?
linux nginx sftp
New contributor
2
I do not know the correct answer, but I judge it has something with SUID SGID and sticky bit. You can get more than 100 hits if looking for that keywords.
– schweik
Nov 16 at 22:31
@roaima Thanks for the comment, you opened my mind. I really had not thought that when a file is modified it was deleted and a new file was created. So I went to check if the creation date was changed, and found that there is no date of creation of a file on linux systems. What I have to do is change the owner of the file again every time I modify it, so nginx will work normally.
– Marcelo
Nov 17 at 22:40
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I gave permission to the user "www-data" in the entire contents of the "/var/www" folder.
However, I work with the root user with a private key via SFTP, and whenever I modify a file, the owner of the file becomes root.
How to edit the files and keep the "www-data" as owner?
linux nginx sftp
New contributor
I gave permission to the user "www-data" in the entire contents of the "/var/www" folder.
However, I work with the root user with a private key via SFTP, and whenever I modify a file, the owner of the file becomes root.
How to edit the files and keep the "www-data" as owner?
linux nginx sftp
linux nginx sftp
New contributor
New contributor
edited Nov 16 at 21:25
Rui F Ribeiro
38.2k1475123
38.2k1475123
New contributor
asked Nov 16 at 21:24
Marcelo
1
1
New contributor
New contributor
2
I do not know the correct answer, but I judge it has something with SUID SGID and sticky bit. You can get more than 100 hits if looking for that keywords.
– schweik
Nov 16 at 22:31
@roaima Thanks for the comment, you opened my mind. I really had not thought that when a file is modified it was deleted and a new file was created. So I went to check if the creation date was changed, and found that there is no date of creation of a file on linux systems. What I have to do is change the owner of the file again every time I modify it, so nginx will work normally.
– Marcelo
Nov 17 at 22:40
add a comment |
2
I do not know the correct answer, but I judge it has something with SUID SGID and sticky bit. You can get more than 100 hits if looking for that keywords.
– schweik
Nov 16 at 22:31
@roaima Thanks for the comment, you opened my mind. I really had not thought that when a file is modified it was deleted and a new file was created. So I went to check if the creation date was changed, and found that there is no date of creation of a file on linux systems. What I have to do is change the owner of the file again every time I modify it, so nginx will work normally.
– Marcelo
Nov 17 at 22:40
2
2
I do not know the correct answer, but I judge it has something with SUID SGID and sticky bit. You can get more than 100 hits if looking for that keywords.
– schweik
Nov 16 at 22:31
I do not know the correct answer, but I judge it has something with SUID SGID and sticky bit. You can get more than 100 hits if looking for that keywords.
– schweik
Nov 16 at 22:31
@roaima Thanks for the comment, you opened my mind. I really had not thought that when a file is modified it was deleted and a new file was created. So I went to check if the creation date was changed, and found that there is no date of creation of a file on linux systems. What I have to do is change the owner of the file again every time I modify it, so nginx will work normally.
– Marcelo
Nov 17 at 22:40
@roaima Thanks for the comment, you opened my mind. I really had not thought that when a file is modified it was deleted and a new file was created. So I went to check if the creation date was changed, and found that there is no date of creation of a file on linux systems. What I have to do is change the owner of the file again every time I modify it, so nginx will work normally.
– Marcelo
Nov 17 at 22:40
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
With sftp
you don't modify a file in place, you copy it to your machine, modify it, and then replace it with the new version, which necessarily then is owned by the user you connected as. Use other means of editing.
sshfs
might be an option; use a sensible editor like vi
;) through ssh
.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
With sftp
you don't modify a file in place, you copy it to your machine, modify it, and then replace it with the new version, which necessarily then is owned by the user you connected as. Use other means of editing.
sshfs
might be an option; use a sensible editor like vi
;) through ssh
.
add a comment |
up vote
2
down vote
With sftp
you don't modify a file in place, you copy it to your machine, modify it, and then replace it with the new version, which necessarily then is owned by the user you connected as. Use other means of editing.
sshfs
might be an option; use a sensible editor like vi
;) through ssh
.
add a comment |
up vote
2
down vote
up vote
2
down vote
With sftp
you don't modify a file in place, you copy it to your machine, modify it, and then replace it with the new version, which necessarily then is owned by the user you connected as. Use other means of editing.
sshfs
might be an option; use a sensible editor like vi
;) through ssh
.
With sftp
you don't modify a file in place, you copy it to your machine, modify it, and then replace it with the new version, which necessarily then is owned by the user you connected as. Use other means of editing.
sshfs
might be an option; use a sensible editor like vi
;) through ssh
.
answered Nov 16 at 23:34
tink
3,91211218
3,91211218
add a comment |
add a comment |
Marcelo is a new contributor. Be nice, and check out our Code of Conduct.
Marcelo is a new contributor. Be nice, and check out our Code of Conduct.
Marcelo is a new contributor. Be nice, and check out our Code of Conduct.
Marcelo is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f482249%2fhow-to-keep-the-user-www-data-when-modify-file-logged-in-as-root%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
I do not know the correct answer, but I judge it has something with SUID SGID and sticky bit. You can get more than 100 hits if looking for that keywords.
– schweik
Nov 16 at 22:31
@roaima Thanks for the comment, you opened my mind. I really had not thought that when a file is modified it was deleted and a new file was created. So I went to check if the creation date was changed, and found that there is no date of creation of a file on linux systems. What I have to do is change the owner of the file again every time I modify it, so nginx will work normally.
– Marcelo
Nov 17 at 22:40