How to run a sudo command on startup?

Viewed 3606

I'm trying to connect to my vpn on startup. I normally enter protonvpn c -f into command line. I have tried the method of creating an rc.local file however it didn't work. This is the code I have inside of it (I got this from a post about a similar issue):

#!/bin/sh -e
/usr/local/bin/protonvpn c CH-NL#1
exit 0

I also made the file executable with chmod +x. Im running Kali 2020.1 if that helps. How do I fix this?

2 Answers

create a file ==> /etc/rc.local

Open and Edit rc.local like below,

replace your command with apt-get update below

#!/bin/sh -e
apt-get update
exit 0

save the edit with Crtl+X

after that

sudo chmod +x /etc/rc.local

then do a reboot and check It should 100% work like a charm

Related