DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
/etc/init.d is where you generally place startup scripts. Then you normally create a link to them from the directory(s) /etc/rc1.d, /etc/rc2.d, /etc/rc3.d, etc., where the number indicates the runlevel. For single user mode the scripts are linked from /etc/rcS.d Debian by default boots to runlevel 2 (at least that's the way mine installed by default). So you'd want to put links in that /etc/rc2.d directory.
The script links take the form of Sxxname where xx are digits. For example, an apache webserver startup script might be linked as S50apache. Lower numbers are run first, so for example S40firewall would run before S50apache. If you want something to kill a server at a given runlevel rather than start it, the link's name starts with a K, e.g., K50apache. These links need to use uppercase S and/or K to actually run. Convention says that if you have something you no longer want to run, but for some reason do not want to totally delete it, replace the first letter with a lowercase. e.g., s50apache would be a link that would not be run. Your actual scripts in /etc/init.d should understand at least "start" and "stop". Check things that you have in these directories as part of the distro base install for examples.
There are different programs that help you manage startup scripts, but the above is what they are doing under the surface. I've always just done it manually myself.
could you point out something for me to read up on all the run levels. I don't know what they are.
I do understand what you said about linking the startup scripts though.
Not much need to read up on the runlevels 2-5 are configured identically in Debian with the default level being 2 (1 is single user rescue mode 6 shutdown) if you wish to create the proper links for your script then check man update-rc.d.
could you point out something for me to read up on all the run levels. I don't know what they are.
Runlevels are what you want them to be. Generally runlevel 0 means reboot, runlevel 6 means shutdown, runlevel 1 is single user. That leaves 2 thru 5 for you to define as you wish. As happytux said, Debian defines 2-5 all the same, but that doesn't mean you can't change them for your own purposes. Think of a runlevel as a collection of services or programs that you want to start/stop as a group. For example, you might decide that runlevel 2 will be your normal multiuser mode (the Debian default). You might then define runlevel 3 as the same as 2, but with an extremely tight firewall setup that blocks all Internet traffic but allows LAN traffic. You just create yourself a tight firewall script and link that into /etc/rc3.d/S40nowan or something like that. Don't forget to add K40nowan scripts to the OTHER runlevels to undo what the S40nowan script did.
To move between runlevels, as root, enter "telinit x", where x is your desired new runlevel. e.g., "telinit 1" to move to single user mode. You can also use the "shutdown" command to move to different runlevels. The "init" command also. Check the manpages. You don't normally go changing runlevels willy nilly on a system with multiple users. You tend to log them off (depending on how you've set things up). They don't always appreciate this. But you're root, and you can do whatever you want! They don't call you the "super abuser" for nothing ;-)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.