~/.profile
, /.bash_profile
, and /.bash_login
are better for defining the environment variables and setting up the environment, than for running scripts. I would not recommend these.
/etc/rc.local
can be used for that, but remember that it will start before GUI starts . Unless it is for a script that only sends notification to GUI. Note that you will need to call your script from /etc/rc.local
in format /full/path/to/script &
(&
to avoid blocking other scripts you may have there from execution). You will also need export DISPLAY=:0
variable in either the script itself or within /etc/rc.local
. Apps that need GUI will need this variable to exist. Same idea with cron job using @reboot
.
If you want to run scripts at GUI login, the proper way is to create .desktop
file for each script in your ~/.config/autostart/
folder. You can do it by hand, or use Startup Applications app that does exactly the same thing for you. Just open the Unity Dash and type in "Startup Applications"
Overview of your examples
apt-get update
doesn't need GUI , just network. /etc/rc.local
is ok for this one.
set some permissions
, this doesn't need GUI too, just use /etc/rc.local
set display brightness
doesn't need GUI too , but may need root privillege. If you want to change it before login , you will need to write to a special file. Consult my other post on this subject
turn numlock on
may not need GUI,too
setup touchpad
depending on your method, may or may not need GUI
run some apps
if they are GUI apps, they will need to be started from Startup Applications I described above.
run some scripts as root
you can use /etc/rc.local
or cron
for these. Running GUI apps as root is bad idea for many reasons, so please avoid that.
run some scripts without root
use the Startup Applications method.
~/.config/autostart
– Sergiy Kolodyazhnyy Jul 18 '16 at 17:48