Linux Start UP Scripts
zdennis "at" mktec.com
Wed Jul 28 19:40:00 2004
Ok this is lengthy. I dont' know how savvy you are on the command line so
bare with me.
There are 7 folders (which are typically found in the /etc directory, if
they are not there search the /etc directory because they may be i another
subdirectory of /etc):
These correspond to the different run levels that Linux has.
- Runlevel 0 is when you turn your computer off.
- Runlevel 1 is single user mode
- Runlevel 2 is multi user mode w/o NFS
- Runlevel 3 is multi user mode w/NFS
- Runlevel 4 is reserved for different vendors to define
- Runlevel 5 is GUI mode.
- Runlevel 6 is when you reboot your computer.
If you look into the rc0.d you'll see a bunch of scripts (or symlinks to
scripts). They either start with a "K" or an "S". When your Linux system
starts into a Runlevel it looks inside of it's corresponding rcX.d folder.
Scripts that start with a "K" are stopped or killed. Scripts that start with
an "S" are started. You'll also notice that after the "S" or the "K" is a
number. When scripts are started it will start "S1script" before
"S99script". The reverse goes for "K1script" and "K99script" (this is killed
If you would like start a script at boot, you need to make a script. For VNC
you can just as easily use a bash script. Copy the following into a file
named "boot.vnc" and place this in the /etc/init.d folder.
/usr/bin/vncserver :1 -geometry 1024x768 &> /dev/null &
##Uncomment the next line to make it run for various users
#su - username -c "/usr/bin/vncserver :2 -geometry 1024x768 &> /dev/null &"
No go into each of the corresponding runlevel folders (rcX.d) of when you
want to start your script. This is normally runlevel 2,3 and 5. So go in
/etc/rc2.d, /etc/rc3.d and /etc/rc5.d. Do an "ls" and look to see what
numbers are available. typically 80 is available. Make a symlink:
ln -s /etc/init.d/boot.vnc /etc/rc2.d/S80boot.vnc
ln -s /etc/init.d/boot.vnc /etc/rc3.d/S80boot.vnc
ln -s /etc/init.d/boot.vnc /etc/rc5.d/S80boot.vnc
Now your vnc will start when you enter runlevel 2,3 and 5. But we still need
to kill it when you turn the computer off or reboot. And we should also kill
it in the runlevels we dont' want to use it in.
ln -s /etc/init.d/boot.vnc /etc/rc0.d/K80boot.vnc
ln -s /etc/init.d/boot.vnc /etc/rc1.d/K80boot.vnc
ln -s /etc/init.d/boot.vnc /etc/rc4.d/K80boot.vnc
ln -s /etc/init.d/boot.vnc /etc/rc6.d/K80boot.vnc
Now reboot your computer. All should be well.
Please don't take everything in this post word for word verbatim for "YOUR"
system. Your system may differ from mine. You may have to look in a
different spot for the rcX.d directories.
I hope this helps all of those wondering about this.
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.725 / Virus Database: 480 - Release Date: 7/19/2004