autoexec.bat? startup commands?

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Madel

autoexec.bat? startup commands?

Post by Madel »

where can I insert my startup commands? like same principle as autoexec.bat where it runs commands during boot up, in win9x.

I just want to insert this commands:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE || echo 1 > /proc/sys/net/ipv4/ip_forward

I just want to start Internet Connection Sharing at boot up. As of now, i have to run that command from the terminal with "sudo -i" so that i can share my internet connection. i don't want the hastle to run those commands manually everytime i start my computer. so instead, i want it to run automatically at boot.

I've tried to install same command in Start Up Applications(applications to start during login) but doesn't seem to work. Perhaps its because of permissions since it needed to run as root.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
gn2

Re: autoexec.bat? startup commands?

Post by gn2 »

One potential solution, right click on a panel, select Add to Panel, then highlight Custom Application Launcher and click Add.
Now a box opens, Application is listed at the top, you can give it a name, next enter the command you want to run (including the sudo bit) next click on the icon, choose one that suits, click OK and you're done.
Now all you have to do to run the command is click on the button in the panel and enter your password.
This gives you the option of whether to run it or not.

Or to add it as a start-up item, in Mint Menu, Preferences > Startup Applications > Add and enter the command you want to run.
Madel

Re: autoexec.bat? startup commands?

Post by Madel »

gn2 wrote:One potential solution, right click on a panel, select Add to Panel, then highlight Custom Application Launcher and click Add.
Now a box opens, Application is listed at the top, you can give it a name, next enter the command you want to run (including the sudo bit) next click on the icon, choose one that suits, click OK and you're done.
Now all you have to do to run the command is click on the button in the panel and enter your password.
This gives you the option of whether to run it or not.

Or to add it as a start-up item, in Mint Menu, Preferences > Startup Applications > Add and enter the command you want to run.
i just want to start it from boot automatically. even without logging in. just turn on computer, then, it's already shared.

It doesn't work in start up applications. i've tried it and doesn't work, that's why im here.
gn2

Re: autoexec.bat? startup commands?

Post by gn2 »

This is what I love about forums, you learn useful stuff all the time :)
Madel

Re: autoexec.bat? startup commands?

Post by Madel »

i don't think this works anymore with Ubuntu based distro since Ubuntu is now using upstart instead of the old system v init script thing.
Thank you. Will try this one if it works.
@update
it doesnt work.
Here's my crontab (root). Is this correct?

Code: Select all

cybergateway ~ # crontab -l
# m h  dom mon dow   command
@reboot iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE || echo 1 > /proc/sys/net/ipv4/ip_forward
cybergateway ~ # 

Madel

Re: autoexec.bat? startup commands?

Post by Madel »

my problem is actually solved but in a different approach. not through startup commands but through following the guide in Ubuntu Iptables site. https://help.ubuntu.com/community/IptablesHowTo

Done this:

Save your firewall rules to a file:
# iptables-save >/etc/iptables.rules

Then:
Alternatively you could add the iptables-restore and iptables-save to the if-pre-up.d and if-post-down.d directories in the /etc/network directory instead of modifying /etc/network/interface directly.

The script /etc/network/if-pre-up.d/iptaload will contain:

#!/bin/sh
iptables-restore < /etc/iptables.rules
exit 0

and/etc/network/if-post-down.d/iptasave will contain:

#!/bin/sh
if [ -f /etc/iptables.downrules ]; then
iptables-restore < /etc/iptables.downrules
fi
iptables-save -c > /etc/iptables.save
exit 0

Then be sure to give both scripts execute permissions:

# chmod +x /etc/network/if-post-down.d/iptasave
# chmod +x /etc/network/if-pre-up.d/iptaload
Been wondering about this "/etc/network/if-post-down.d/" and "/etc/network/if-pre-up.d/" , is this the new startup directories used in upstart? im just curious about this 2 directories.
Locked

Return to “Installation & Boot”