I am having trouble writing files to a usb drive in /media/usb via python file.write(). How do I run the python script with sudo ? And, since it should be automatic, how would i avoid to type in the password?
It's nothing about python script, but linux user permissions.
You can have the following options (choose one),
sudo
to elevate user priviligeTo avoid password prompt, you can add a sudoers file under /etc/sudoers.d/
, e.g.
echo "$USER ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$USER