Sometimes we might want some set of things to happen on startup. If it is a simple application/script we can simply add to startup applications. However this fails if we need to be root to run that. Today i will show you how it is done.
Say I want to mount a set of disk drives on startup.
- Open Terminal and type
$ gedit mounter.sh
- Type the set of commands you want to run on startup in this file. Here it is
mount /dev/sda2 /home/alse/Ambusher
mount /dev/sda3 /home/alse/C
- Save and close the file. Now change permissions of the file.
$ chmod +rwx mounter.sh
- Then move it to /etc/init.d
$ sudo mv mounter.sh /etc/init.d/
- Add mounter.sh to rc.d
$ sudo update-rc.d mounter.sh defaults
Now mounter.sh will run on startup.
Now I will show you how to remove something which you have already added
Suppose say i want to remove mounter.sh from rc.d. Type
$ sudo update-rc.d -f mounter.sh remove
Now you can just execute the script by adding in /etc/rc.local