Need to Change $Euid Value to Non-Zero in the Bash Shell
I Have a Script(Test1. Sh) Like the Below and I Need to Run It as Root Because as a Prerequisites, We Need to Install a Couple of Packages When It Enters into...
I have a script(test1.sh) like the below and i need to run it as root because As a prerequisites, we need to install a couple of packages when it enters into this script, value $EUID should be non-zero, Coul you help me to change this $EUID value
test1.sh
#!/usr/bin/env bash
....
.....
if [[ $EUID -eq 0 ]]; then
echo "This script must be run as nonroot user. Otherwise, couple of test cases will fail."
exit 1
fi
.........
..........
.............
.....
..
.
.
.
.............
Thank you
1 Answer
Read man sudo and use -u user, e.g.
sudo -u nobody /path/to/the/script