Debian VPS Setup software power-on self start step

Source: Internet
Author: User


Debian boot Process

1. Init Run Level

In the Linux startup process, I introduced the process of Linux startup. Where, in step fifth, the INIT program is loaded and the configuration file is/etc/inittab, which specifies that Init executes the/etc/init.d/rcs script that executes the script under the/etc/rcs.d/directory through the subprocess, such as detecting the mounted file system, Reprint kernel module, start Network Service, set clock and other initialization work. Then, for compatibility, the/etc/rc.boot/directory is executed, and all file names do not contain "." of the file.

After the startup process, the INIT program executes the startup script in the default run level and the run level is specified in the/etc/inittab file. Linux has 7 levels of running.

0 System shutdown Status
1 single user or system maintenance status
2~5 Multi-user status
6 reboot
corresponding to the/ETC directory there will be RC0.D, rc1.d 、、、 rc6.d such six directories, corresponding to each run level. The RCN.D directory is a link to the script in Init.d, in fact, the files in either/etc/rcn.d/directory are a symbolic link to/etc/init.d/. The file naming method in the Rcn.d/directory determines which script will run, "K" starts at the run level by default and executes the appropriate script, killing the service. And all s begin, and are executed when the run level is entered. The two digits after the letters specify the order in which to start, and the smaller numbers are executed first.

At machine boot time, init starts at run Level 0 and runs up to the default run level set in/etc/inittab. The default operating level of the Debian system is id=2, which means that the script under/ETC/RC2.D will run in multi-user state.

2,/etc/rc.local

Rc.local is also a commonly used script. The script is executed after the system initialization level script is run, so it is safe to add scripts that you want to execute after the system starts.

Setting the software self-startup method

There are two common approaches: modifying/etc/rc.local and adding a boot service. The second method is recommended.

1. Modify/etc/rc.local

Edit/etc/rc.local

Vi/etc/rc.local

In front of exit 0, add the scripting code to Shadowsocks for example:


/etc/init.d/shadowsocks-libev start
Exit 0

2. Add Boot Service

First you need to execute the script in the/etc/init.d/directory

Then add the service in the following way


UPDATE-RC.D XXX Defaults

In fact, the function of the command is to establish a soft connection in the six directories of RC0.D, rc1.d 、、、 rc6.d.

Also take shadowsocks as an example, first look at the next/etc/init.d/directory there is no Shadowsocks-libev, after viewing does have.
Then execute the following command:

UPDATE-RC.D Shadowsocks-libev Defaults

That's it.

If you want to remove the boot service, you can use the following code

update-rc.d-f XXX Remove

Summary

This article describes two ways to set up a Debian startup: Modify the/etc/rc.local and add the boot service method.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.