Saturday 1 December 2012

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

2 comments:

  1. Thanks a lot!! I used this post to integrate my windows desktop, downloads, pictures and so on with that in ubuntu!! yaay!
    Step 0: auto mount C drive as shown in the post
    Step 1: delete all the folders u wanna integrate. rm -r ~/Desktop ~/Downloads ~/Pictures
    Step 2: Then the following for all of folders:
    ln -s /Users/Tim/Desktop ~/Desktop
    ln -s /Users/Tim/Downloads ~/Downloads
    ln -s /Users/Tim/Pictures ~/Pictures
    and so on

    Now no matter what OS i use i view the same content!!!

    ReplyDelete