Executing Commands as Different Users in Bash
Here’s an example of running echo but as a consul user:
sudo -H -u consul bash -c 'echo "I am $USER, with uid $UID"'
Here’s an example of running echo but as a consul user:
sudo -H -u consul bash -c 'echo "I am $USER, with uid $UID"'