0

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.

Zac
  • 237
  • 1
  • 2
  • 5
  • 2
    `sudo echo …` affects `echo`, not `tee`. You don't need `sudo` to `echo`. Can you take it from here? – Kamil Maciorowski May 15 '20 at 04:54
  • @KamilMaciorowski Thanks! I added sudo before tee and that seems to have done it. However, I received a private message about this being a duplicate question about file's write permission, and my file does have write permissions, so it's inaccurately marked duplicate. – Zac May 16 '20 at 03:09
  • `my file does have write permissions` – Not for the user `test`, apparently. The file certainly has ownership and mode bits. The user `test` does not have write permission and this is normal after you created the file with `sudo fallocate …`. – Kamil Maciorowski May 16 '20 at 07:07
  • @KamilMaciorowski Sorry, I don't follow what you are saying. I replaced my username with 'test' just to post this question. Not sure if that helps. – Zac May 19 '20 at 01:16
  • If you believe the question is inaccurately marked duplicate then show us. You said `my 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 user `test` to write. And it's normal after you used `fallocate` with `sudo` on a nonexistent file, thus creating it with `root` as the owner. If it's not like this then please [edit], show the output of `ls -l text` or something and convince us the question is not a duplicate. It most likely is and [this answer](https://unix.stackexchange.com/a/1417/108618) helps. – Kamil Maciorowski May 19 '20 at 05:17

0 Answers0