zlacker

[parent] [thread] 11 comments
1. kayson+(OP)[view] [source] 2026-02-05 05:41:27
> sudo echo $NUM_PAGES > /proc/sys/vm/nr_hugepages

This won't work :) echo will run as root but the redirection is still running as the unprivileged user. Needs to be run from a privileged shell or by doing something like sudo sh -c "echo $NUM_PAGES > /proc/sys/vm/nr_hugepages"

The point gets across, though, technicality notwithstanding.

replies(2): >>thayne+E >>timeto+g3
2. thayne+E[view] [source] 2026-02-05 05:49:11
>>kayson+(OP)
Or

    echo $NUM_PAGES | sudo tee /proc/sys/vm/nr_hugepages 

I've always found it odd that there isn't a standard command to write stdin to a file that doesn't also write it to stdout. Or that tee doesn't have an option to supress writing to stdout.
replies(4): >>axioli+K1 >>TheDon+7s >>vbezhe+Ua1 >>wang_l+jX1
◧◩
3. axioli+K1[view] [source] [discussion] 2026-02-05 06:00:00
>>thayne+E
You forgot the "sudo" before "tee"

> write stdin to a file that doesn't also write it to stdout

You mean like "dd of=/path/file" ?

replies(1): >>zdragn+Nk1
4. timeto+g3[view] [source] 2026-02-05 06:16:21
>>kayson+(OP)
Great point, I was running as root so I didn't pick this up. Corrected, thank you!
◧◩
5. TheDon+7s[view] [source] [discussion] 2026-02-05 09:53:40
>>thayne+E
> I've always found it odd that there isn't a standard command to write stdin to a file that doesn't also write it to stdout

If you happen to have moreutils installed, you can do that with pee

    echo $NUM_PAGES | sudo pee 'cat > /proc/sys/vm/nr_hugepages'
replies(1): >>direwo+PD
◧◩◪
6. direwo+PD[view] [source] [discussion] 2026-02-05 11:37:18
>>TheDon+7s
why not write sh -c then?
replies(1): >>TheDon+UJ
◧◩◪◨
7. TheDon+UJ[view] [source] [discussion] 2026-02-05 12:33:58
>>direwo+PD
Because 'sh' isn't in moreutils and is harder to remember, next question.

Why use something portable when you can use cat pee?

replies(1): >>semiqu+wq1
◧◩
8. vbezhe+Ua1[view] [source] [discussion] 2026-02-05 15:20:02
>>thayne+E
I've always thought that there should be `cat -o output-file` flag for that. GNU coreutils have miriads of useless flags and missing one actually useful flag LoL.

And probably `echo -o output-file` as well.

◧◩◪
9. zdragn+Nk1[view] [source] [discussion] 2026-02-05 16:13:36
>>axioli+K1
I physically/literally squinted when I saw disk destroyer.

I know it's useful for other things, but it has become a fearful instinct at this point.

◧◩◪◨⬒
10. semiqu+wq1[view] [source] [discussion] 2026-02-05 16:45:11
>>TheDon+UJ
Personally? Because I hate the smell.
◧◩
11. wang_l+jX1[view] [source] [discussion] 2026-02-05 19:08:10
>>thayne+E
It’s not an option or feature because it’s built into the shell. Just slap a > /dev/null on the end.
replies(1): >>thayne+7e2
◧◩◪
12. thayne+7e2[view] [source] [discussion] 2026-02-05 20:21:55
>>wang_l+jX1
That works, but it feels wasteful to needlessly copy it, and it is verbose.
[go to top]