Etc/rc. d/command explanation under centos6.5

Source: Internet
Author: User

Etc/rc. d/command explanation under centos6.5
1./etc/rc. localThis is a user-defined boot Startup Program. Write the program that needs to be automatically started into this script. If I want to complete other actions after the run level 3 service is started, for example, if I want to send a mail to a system management account to notify him that the system has just restarted, should I create a shell script and place it in/etc/rc. d/init. d/, and then link to/etc/rc. what about d/rc3.d? Haha! Of course not required! /Etc/rc. d/rc. localThis file can execute the system commands you want to execute.

That is to say, if I want to write/etc/rc. local directly when I start my job, this job will be automatically loaded when I start it! Instead of waiting for us to log on to the system to start it! Is it convenient! Generally, laruence prefers to write the full file name of the shell script he created into/etc/rc. d/rc. local, so that the startup will execute my shell script. That's great!
-------- Reference ----------------------
That is to say, in the last phase of linux Startup, the system will execute the command stored in rc. local. It is similar to the "Start" menu in windows.
Usage:

1) oracle and other server startup: If you need your oracle to start with the system, you can check the/etc/oratab file and learn about it, you will find that this is where it is.

2) Static Routing: many users prefer to add similar routes in/etc/rc. d/rc. local when they need to add a large number of routes not in this segment.

Route add-net 192.168.1.0 netmask 255.255.255.0 gw 10.224.0.20.

Route add-host 192.168.100.1Gw 10.224.0.20.

2./etc/init. d

This directory stores some scripts, usually the startup scripts of some services set during rpm package installation. The system has installed many rpm packages, and there are many corresponding scripts. Run these scripts to start, stop, and restart these services. For example, if you want to restart sendmail and your sendmail is installed with rpm, release/etc/rc. d/init. d/sendmail restart can start sendmail directly!
As mentioned above, the script in the directory/etc/rc. d/init. d is similar to the Registry in windows and executed when the system is started. The program runs here (the init process reads the running level. d script, but it is not directly run, but has a choice because the system does not need to start all services.
Then, how does the system choose what needs to be started and what does not? At this time, the running level just mentioned takes effect. After the run level of the system is determined, the script/etc/rc. d/rc is executed first. After knowing the running level, each running level has a subdirectory named rc0.d and rc1.d under rc. d ..... Rc6.d. Each directory contains links to some scripts in the init. d directory. The services to be executed at each level are under the corresponding directory. For example, the services to be started at level 5 are placed under rc5.d, but some link files are put under rc5.d, link to init. d. d.

The content of rc. d is as follows:
Init. d/: directory for storing binary files of various servers and programs.
Rc (x). d/: directory for connecting execution programs at various startup levels. Everything in it is a soft connection pointing to init. d. The details are described later.
There are three other scripts: rc. sysinit, rc, rc. local

The centos Startup Mode and execution sequence are as follows:

Load the kernel
Run the init program
/Etc/rc. d/rc. sysinit # The first script executed by init
/Etc/rc. d/rc $ RUNLEVEL # $ RUNLEVEL is the default running mode.
/Etc/rc. d/rc. local
/Sbin/mingetty # Wait for User Login

/Etc/rc. d/rc. sysinit mainly performs the same initialization in each running mode, including:
Incoming keymap and system font
Start swapping
Set Host Name
Set the NIS domain name
Check (fsck) and mount the File System
Open quota
Mount sound card module
Set system clock
And so on.

/Etc/rc. d/rc executes scripts in the corresponding directory according to the running mode specified by its parameters (the running level, which can be set in the inittab file. Anything that starts with Kxx
All are called with the stop parameter. All parameters starting with Sxx are called with the start parameter. The call order is xx.
From small to large. For example, if the default running mode is 3,/etc/rc. d/rc will call
Scripts under/etc/rc. d/rc3.d.
Run Mode 2, 3, and 5. d/rc. as the last part of the initialization script, you can add some commands in this file that need to be executed before logon after other initialization tasks.


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.