sudo and Redirection
sudo echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/99-fw.conf fails with "Permission denied". Why?
sudo echo "net.ipv4.ip_forward=1" > /etc/sysctl.d/99-fw.conf
Choose one answer
The redirection > is performed by your (unprivileged) shell before sudo runs, so the file is opened without root rights.
>
echo cannot be run with sudo.
echo
sudo requires the -E flag for echo.
-E
The file name must end in .sysctl.
.sysctl