How to run a sudo command on startup?

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?

Upvotes: 3

Views: 7619

Answers (2)

Tamil Selvan
Tamil Selvan

Reputation: 1749

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

Upvotes: 2

Jeff Huang
Jeff Huang

Reputation: 581

This solution should work for ubuntu systems.

https://askubuntu.com/a/290107/1051584

Kali is debian based so I believe this will probably work as well.

Upvotes: 0

Related Questions