This is my output on CentOS.
[test@test]$ sudo fallocate -l 2M text
[test@test]$ sudo echo “This is for test” | tee text
tee: text: Permission denied
“This is for test”
[test@test]$ ls
text
[test@test]$ cat text
[test@test]$
[test@test]$ sudo yes 'This is test' | dd of=text bs=2M count=1
dd: failed to open ‘text’: Permission denied
I keep getting the 'Permission denied' error. But I have sudo permissions.
sudo echo …
affectsecho
, nottee
. You don't needsudo
toecho
. Can you take it from here? – Kamil Maciorowski May 15 '20 at 04:54my file does have write permissions
– Not for the usertest
, apparently. The file certainly has ownership and mode bits. The usertest
does not have write permission and this is normal after you created the file withsudo fallocate …
. – Kamil Maciorowski May 16 '20 at 07:07my file does have write permissions
and I'm saying (1) it does have some permissions, i.e. mode bits (2) but apparently they do not allow the usertest
to write. And it's normal after you usedfallocate
withsudo
on a nonexistent file, thus creating it withroot
as the owner. If it's not like this then please [edit], show the output ofls -l text
or something and convince us the question is not a duplicate. It most likely is and this answer helps. – Kamil Maciorowski May 19 '20 at 05:17