I have a file
-rw-rw-r-- 1 root mygroup 0 Sep 10 14:54 /etc/nginx/mygroup.txt
The access rights are set so that the group
mygroup has read and write permissions for the file. Writing the file with a member of
mygroup works when editing with
vi /etc/nginx/mygroup.txt. However, when I try to append a text to the file with the same user using
echo "blaa" >> /etc/nginx/mygroup.txt
-sh: 3: cannot create /etc/nginx/mygroup.txt: Permission denied
The directory permission for the containing directory are
drwxr-xr-x 6 root root 4096 Sep 10 16:07 nginx
The user is able to list the contents of the directory.
Why does this happen and how can I add a line to the text file from bash without using a text editor?
Additional information based on comments:
The user has no sudo rights.
Is this a duplicate of Why can't sudo redirect stdout to /etc/file, but sudo 'nano' or 'cp' can? ? I don't think so, because running
printf "blaa" | tee /etc/nginx/
tee: /etc/nginx/whitelist-jutik.txt: Permission denied
Also all the other suggested duplicate questions are for users with sudo rights, so I think this question is not a duplicate of any of them.
Edit: finding this question solved the problem: Group member cannot write even with write permission
Apparently the group permissions were not completely in effect. Logging in again with the user solved the problem, he can write the file with both vi and echo.