0

This question already has an answer here:

I have a python script that restarts the mouse driver

import os

os.system("sudo modprobe -r psmouse")
os.system("sudo modprobe psmouse")

since my mouse doesn't always show up on start. What is a way I can run it on start up without being prompted for a password?

marked as duplicate by mikewhatever, Jacob Vlijm, Videonauth, Eric Carvalho, muru Dec 18 '16 at 18:20

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    Use subprocess.Popen() or -call. os.system is terribly outdated, deprecated and old fashioned. – Jacob Vlijm Dec 16 '16 at 18:55
0

OP should have asked, "how do I load a kernel module on boot?"

Edit the /etc/modules file and add the name of the module (without the .ko extension) on its own line. On boot the kernel will try to load all the modules named in this file.

Source: How to install 3rd party module so that it is loaded on boot?

0

You can edit your sudoers file so that a given user can execute a specific script without a password request.

Example:

someusername    ALL=(ALL) NOPASSWD: /some/path/to/script/somescript

Similar Post / Reference: How do I sudo a command in a script without being asked for a password?

  • If it's a dupe, please mark it as such, instead of re- answering. – Jacob Vlijm Dec 16 '16 at 18:58
  • It is not a dupe of the question you linked. The person asking a question simply asked it wrong. OP should have asked, "how do I load a kernel module on boot? – Sam Gleske Dec 16 '16 at 19:24
0

If you just want to reload the mouse drive on start up, it may be more convenient to include the commands in /etc/rc.local. rc.local runs as root, so you don't need any sudo commands. By default it just contains comments and and exit 0 command. Assuming that you have the default rc.local, edit it to look (something like) like this:

#!/bin/sh -e
modprobe -r psmouse
modprobe psmouse
exit 0

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