Re: How to run automatically a script as soon root login
On Mon, May 13, 2024 at 01:48:25PM +0200, Mario Marietto wrote:
> I wouldn't to login as root automatically,but I've realized that this
> command :
>
> echo 1 > /proc/sys/net/ipv4/ip_forward
>
> work only if I'm root. It does not work using sudo. So,in the end I've
> chosen to be root instead of a normal user that can use sudo.
Aha! Classic X-Y problem.
To do this with sudo, you can use a shell:
sudo sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
However, this particular setting can also be done with sysctl:
sudo sysctl -w net.ipv4.ip_forward=1
Or if you just want the setting to be made permanent, edit the
/etc/sysctl.conf file, find the line that says:
# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1
and remove the # sign in front of net.ipv4.ip_forward=1 and then you
will never have to issue your command manually again.
Reply to: