I'm new at linux and I'm trying to run this command as sudo:
sudo python script.py
Te command contains relative path to home, but I'm getting /root/
as the home folder instead /home/My_User/
Is there a way to run the script with sudo privileges without being promoted to root as user?
You can use
sudo -E python script.py
to gain the elevated privileges but retain your user environment.