Tee

From DikapediaV2
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