Tuesday, April 30, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1230  / 2 Years ago, tue, march 1, 2022, 10:05:10

I have a below command which I have to run manually each time whenever the Ubuntu machine starts or reboots.


ngrok start --all

This command can only be run without sudo. If I run it as sudo ngrok start --all, it gives error. Due to this I am not able to create script which I can run as systemd service, so that the service automatically starts on every boot and executes the script and the command starts.


I have also tried crontab by adding below line to sudo crontab -e but it also didn't worked.


@reboot ngrok start --all

How can I run above command without sudo on startup of Ubuntu. Can anyone please help. Thanks


More From » command-line

 Answers
3

At that time, it already runs with root privileges, so there is no need to use sudo. Just run it without it.


You only need sudo when you are logged in, and a program runs using your user account with less privileges; sudo gives such a program root privileges. Processes started during system startup or in (root's) crontab already run as root.


There is even a solution how to run this as a systemd unit:


https://github.com/vincenthsu/systemd-ngrok


[#1588] Tuesday, March 1, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ongdiligenc

Total Points: 452
Total Questions: 111
Total Answers: 107

Location: Ukraine
Member since Sun, Dec 13, 2020
3 Years ago
ongdiligenc questions
Wed, Apr 13, 22, 10:34, 2 Years ago
Tue, Jun 7, 22, 00:54, 2 Years ago
Sat, Aug 7, 21, 00:37, 3 Years ago
Sat, May 22, 21, 03:06, 3 Years ago
;