Tee

From DikapediaV2
Revision as of 14:31, 11 September 2024 by Ardika Sulistija (talk | contribs) (Created page with "https://askubuntu.com/questions/103643/cannot-echo-hello-x-txt-even-with-sudo If you have to write to a file in a script using sudo like <b>sudo echo "word" > file</b> won't work because the redirection is done by the shell before sudo is even started. So make sure the redirection happens in a shell with the right permissions by using <b>tee</b>, like so: echo "blacklist nouveau" | sudo tee /etc/modprobe.d/denylist.conf Use <b>-a</b> to append: echo "options nouveau...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

https://askubuntu.com/questions/103643/cannot-echo-hello-x-txt-even-with-sudo

If you have to write to a file in a script using sudo like sudo echo "word" > file won't work because the redirection is done by the shell before sudo is even started. So make sure the redirection happens in a shell with the right permissions by using tee, like so:

echo "blacklist nouveau" | sudo tee /etc/modprobe.d/denylist.conf

Use -a to append:

echo "options nouveau modeset=0" | sudo tee -a /etc/modprobe.d/denylist.conf