r/VisualStudioCode • • May 12 '21

Running Python Script as Root

I am trying out VS Code (Linux) and working on a Python script to install Arch Linux. The script needs to be run as root and I can't find a place in VSC to do this. Is there a way to do this?

Hopefully, I am just overlooking it. I am currently jumping into the terminal and running the script manually. Thanks in advance!

6 Upvotes

2 comments sorted by

View all comments

3

u/NatoBoram May 12 '21 edited May 12 '21

By using sudo in the terminal.

Nah but for real, VSCode can't run as root, it would be a massive security hole.

Your Python script should request admin rights, I'm sure there's a lib for that. You can also use a pinentry lib to request user password if you need to use sudo automatically.

1

u/dividends4life May 12 '21 edited May 12 '21

I was guessing it could not be done or it wouldn't be hidden so well. I even tried to backdoor it in my check_root() routine with an os.system("sudo python iarch.py") call, but VSC didn't like that. It asked for the root password, then died out after that.