Friday, September 1, 2017

Run anything on startup in ubuntu

Run anything on startup in ubuntu



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.




  1.  Open Terminal and type
    gedit mounter.sh
  2. 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
  3. Save and close the file. Now change permissions of the file.
    $ chmod +rwx mounter.sh
  4. Then move it to /etc/init.d
    $ sudo mv mounter.sh /etc/init.d/
  5. 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

Update:

Now you can just execute the script by adding in /etc/rc.local


download file now

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.