Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to run the python script, when I startup the Linux machine. How can I do so? I don't need the user to login the OS to start the script. (The user is password protected.)

share|improve this question
What distribution? Are you using upstart, systemd, or something else? – David Schwartz Aug 23 '12 at 12:42
Have you done much research into this? The top results when Googling your question comes up with links that say the exact same thing as the below answer from mnmnc. – bobmagoo Aug 23 '12 at 12:58
possible duplicate of How do I make a script run upon startup of the Ubuntu machine? – Indrek Aug 23 '12 at 17:46
@Indrek: It's not an exact duplicate, since this post does not specify Ubuntu, while the question is somewhat distro-specific. – grawity Aug 23 '12 at 18:50

Generic method – add the script to /etc/rc.local:


if your python interpreter is under /usr/bin, or simply


if your script is marked executable (+x).

Note that some systems use /etc/rc.d/rc.local instead.

On systemd systems, rc.local might be ignored completely.

Create a service unit, /etc/systemd/system/something.service:

Description=Script name



Tell systemd to start the script on boot with systemctl enable something.service.

share|improve this answer
Although Ted explicitly asks about OS startup and not about user login, the proper place for post-login scripts is .profile, .xprofile and/or .config/autostart/. Adding something to .bashrc will cause it to be run every time a terminal is opened. – grawity Aug 23 '12 at 17:15
i stand corrected. Thank you. – mnmnc Aug 23 '12 at 17:19
Just to note: on some systems, the file may be located at /etc/rc.d/rc.local. – clpo13 Aug 23 '12 at 17:44
@clpo13: And some systems might not be using rc.local at all (such as most systemd-using Linux distros)... – grawity Aug 23 '12 at 17:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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