Instructions for Ubuntu runlevel, boot startup scripts

Source: Internet
Author: User

Instructions for Ubuntu runlevel, boot startup scripts

Catalog Introduction

1.1 Introduction to Ubuntu under the self-startup script directory

1.2 Linux operating system operational level concept

1.3 about the boot sequence of the operating system self-starter scripts

1.4 Linux operating system operational level concept

1.5 self-start and shutdown services

1.6 for the init [number] Command

Content:

1.1 Introduction to Ubuntu OS several directories for self-startup scripts

Where the RC0.D~RC.6.D folder corresponds to the operating system level 0-6 running state needs to execute the script. There are also RCS.D folders and rc.local files, and the files under these folders are soft-chain files that point to the script at the specified location, as shown in the diagram:

After viewing, these soft links are found to point to the same folder. /init.d/'s script file,

We looked at the other folders and found this to be the case. So all the boot-boot script files are placed under the/etc/init.d/directory:

So what do these rcn.d mean, respectively? Or are they running in 0~6 order? Definitely not. Because we view Rc0.d folder

found that in this folder, there is actually a halt (shutdown) script, so when the operating system opened, it is certainly impossible to do this. It is therefore proved that rcn.d these folders are independent of each other and have no essential connection.

So why is there a difference between these few folders? This introduces the operational level (Run-level) concept of the Linux operating system.

1.2 Linux operating system operational level concept

According to the previous study, we know that there are rc0~6 in the RCS.D & Rc.local, the latter two we do not see, there are at least 0-6 of the total seven operating levels. The concept of runlevel here is known as the operating mechanism of System V. The meanings of these seven runlevel are as follows (for Ubuntu only, other system definitions may not be exactly the same):

We can view the current system's operational status through RunLevel

That is, the operating level of our system is currently 2, the configuration file for this parameter/etc/init/rc-sysinit.conf

So we boot the script in the Rc2.d folder, all the soft links to the script files in the/etc/init.d/:

These are our default boot state, to start the service, if we put our own script in the/etc/init.d/directory, while creating a soft chain in rcn.d, point to the file (the name of the soft chain should be s<num><service name> will be able to start these services. We can also modify the value of Default_runlevel in the configuration file/etc/init/rc-sysinit.conf and modify the operating system default RunLevel.

1.3 about the boot sequence of the operating system self-starter scripts

Assuming that our operating system is running at 2, what is the sequence of script execution under the/etc/rc2.d/folder? Because some services need to start first, some services need to start, they have a succession relationship, that is, the relationship to the graph.

We look at the name of the soft chain under this folder (see), the name of the soft chain has certain rules:

S[number][service name]--. /init.d/servicename

S = start, start service

[number] represents the run priority of the script, the smaller the number, the higher the priority of the script to run

[Service Name] represents the name of the service.

So if we need to define the priority (order) of a service startup, you need to specify the number of the script.

According to this rule, we view the Rc6.c folder (restart RunLevel):

In the order of number, the kill service is displayed, then start some services, and then restart S90reboot.

1.4 about the meaning of the RCS.D rc.local folder

The script is executed under the script command under the RCS.D folder before the script executes under the RC0~6.D folder.

1.5 self-start and shutdown services

After understanding the principle of the self-service, we can manually add the script link file to the specified RCN.D directory, but this purely manual way is more complex, so we can use simple commands to implement this function, or the specified tool to implement.

Command version # UPDATE-RC.D to automatically implement the RunLevel startup scripting service for System V, provided that the startup scripts for these services are located in the/etc/init.d/directory.

UPDATE-RC.D <service name> start|stop| <order number> <run levels>

eg

sudo update-rc.d rinetd start 20 2

sudo update-rc.d rinetd stop 20 0

UPDATE-RC.D <service name> enable|disable <runlevels> # Open or Forbidden

eg

sudo update-rc.d rinetd Disable 2 temporarily disables the service in Runlevel2

UPDATE-RC.D <service name> default [NN | SS KK]

eg

sudo update-rc.d rinetd default 2 3 4 5 Add the start of the first 80 order, and in 0 6 add the Kill service in the order of (the second 80)

Note implement go to the corresponding folder to view the ordernumber of the service

Remove from startup

sudo update-rc.d-f <service name> Remove

This will remove the self-start and close service links (only the links, not the script files in the/etc/init.d/folder) from the services at all RunLevel.

1.6 for the init [number] Command

We shut down the operating system at the command line or reboot, using the

In essence, the call is:

RC0.D indicates that the shutdown RC6.D represents a reboot

Therefore, we can also switch the operating system RunLevel without restarting the operating system.

sudo init <num>

GuangZhou 2016-8-6

Instructions for Ubuntu runlevel, boot startup scripts

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.