Im attempting to run a command as root but it is not working and I think the reason why is because when running the command sudo is not setting $HOME to /root but keeping it as /home/MYUSER the command im running is:
$ sudo -H -u root bash -c "echo $HOME"
/home/MYUSER
Ive also tried the following which results in the same:
sudo su -c "echo $HOME" root
Note the actual issue im having is trying to run kubectl commands which MYUSER does not have access to do so the command im actually trying to execute is:
sudo -H -u root bash -c "kubectl get pods"
[sudo] password for MYUSER:
The connection to the server localhost:8080 was refused - did you specify the right host or port?
I think the issue is the $HOME thing because /root has the .kube directory but /home/MYUSER does not.