How can I start a command as superuser at startup on Xubuntu? Normally I enter any command in the option 'Session and Startup -> Application Autostart', but I don't know how to do it as superuser since if I enter the command preceded by sudo or pkexec nothing happens (I also don't want to be asked for the password at startup, since I have already logged in).
51 Answer
I've finally fixed it by adding the hdparm command in sudoers. For this I have run sudo visudo and added the following line (important that it be added to the end of the file for the rule to apply): MY_USER ALL=(root) NOPASSWD: /sbin/hdparm, replacing "MY_USER" by my user.
Once this is done we can add the command in the "Start Applications" menu. The command must also have "sudo" in front.
In this thread there is a very similar case: [Run script as root immediately after login to gui