I have been trying to get my script run right after I reboot. I have tried editing the rc.local
file without success. After that I tried to add an entry to Startup Applications with the path to my script /home/user/Scripts/myScript.sh
.
Then my system rebooted running the wanted script. The problem obviously isn't with execution privileges (which I've added with chmod
command) but with denied access, because the command was not run with root privileges. Since gksu
and gksudo
is no longer supported, I was wondering how could I work around this problem.
I am running Ubuntu 18.04, 64-bit
I also now found, that running rc.local
does run the script, however it does not run on startup
Permissions of the script:
user@d4tor:~$ ll /home/user/Scripts/myScript.sh
-rwx--x--x 1 user user 129 July 3 16:50 /home/user/Scripts/myScript.sh*
Permissions of rc.local
:
user@d4tor:/etc$ ls -l rc.local
-rwxr-xr-x 1 root root 328 July 5 17:45 rc.local
ll /home/user/Scripts/myScript.sh
andcat /home/user/Scripts/myScript.sh
?/etc/rc.local
will absolutely certainly be run as root upon system startup, if it exists and it is executable. You may be making a confusion between system startup and the start of a graphical session for a user. (A system can run happily without having any user loggen in in a graphical session.) They are not the same thing, and do not run the same scripts. There is very little reason to run a script as root in a user's graphical session; there is never any good reason to run a GUI program as root.pkexec
to run as root. You can read the first answer here: askubuntu.com/questions/383747/… to see how to let a program use pkexec without password, and then your script should work.