Suppose I am writing a shell script that requires root privileges to run, for example-
#!/bin/sh ip -s -s neigh flush all ufw enable
How can I prevent certain lines of code to be run as root, i.e. suppose I add a line in the above script which starts the TOR browser .
#!/bin/sh ip -s -s neigh flush all ufw enable sh -c '"/home/back/Downloads/tor-browser_en-US/Browser/start-tor-browser" --detach || ([ ! -x "/home/back/Downloads/tor-browser_en-US/Browser/start-tor-browser" ] && "$(dirname "$*")"/Browser/start-tor-browser --detach)' dummy %k
As TOR always run in non root mode, what changes should I make in the above script to allow execution of tor as non-root user and rest of the script as root user ?