I am setting up a machine that's sole purpose is to run a specific python application that uses a curses ui. That being said, there are some aspects of the application that require it to be run as su.

How can I run this application on login so the user doesn't need to execute it every time? I have seen Is there a script that runs as root when user logs in? and it seems different than mine as they don't actually require su there.

I really don't care about security at all for this application, it's not online nor will it ever be online. I don't even care if I have to enter my credentials twice either. I just want it to execute the line:

sudo python ~/Application/main.py

on login. If there's a more efficient way where I don't have to enter credentials twice, that would be even better. This has to work on Ubuntu Server as well.

1 Answer 1


I found a solution through this stack overflow answer: https://stackoverflow.com/questions/4128817/how-can-i-execute-a-command-when-i-first-login-to-my-unix-server which works for me. I just added

cd ~/Application
sudo python main.py

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.