Linux boot process and service control

Source: Internet
Author: User

Boot process and service control

Requirements:

? Set the Linux system to automatically enter the character mode interface after each boot.

Steps:

Edit the/etc/inittab file to change the default run level to 3. :

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" clip_image003 "border=" 0 "alt=" clip_image003 "src=" http://s3.51cto.com/wyfs02/M02/77/5D/ Wkiol1zmtcrbgch2aaaflogiufu115.png "244" height= "/>650" this.width=650; "style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" clip_image005 "border=" 0 "alt=" clip_image005 "src=" http://s3.51cto.com/wyfs02/M01/77/5E/ Wkiom1zmtvvbb1snaaa3uq4wgvg106.png "" 244 "height=" 137 "/>

? Use the NTSYSV tool to adjust service status in the 2, 3, 4, 5 runlevel at the same time, and turn off the following services: Anacron, ATD, Avahi-daemon, Bluetooth, cups, Firstboot, Hidd, Hplip, Ip6tables, Iptables, ISDN, Mcstrans, Mdmonitor, Nfslock, PCSCD, Portmap, Restorecond, RHNSD, RPCGSSD, RPCIDMAPD, SendMail, Setroubleshoot, XFS, xinetd, yum-updatesd.

Steps:

Use Ntsysv tool: (not valid until reboot)

The Ntsysv tool can be run in character mode, providing users with a graphical interactive interface that is designed to centrally configure the startup state of various system services. Using the Ntsysv tool is handy when you need to set the startup state of multiple services at the same time.

The NTSYSV command is only used to manage services in the current runlevel: The--level option allows you to manage services in the specified runlevel. :

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" clip_image007 "border=" 0 "alt=" clip_image007 "src=" http://s3.51cto.com/wyfs02/M02/77/5E/ Wkiom1zmtvyqqhzkaaafvlbzbeu826.png "" 244 "height="/>

Press the UP and DOWN ARROW keys to select the above system services, press SPACEBAR to set the default startup status of the service ("[*]" means start, "[]" means close). If you want to know the description of the selected service. Press the F1 key to get help. :

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" clip_image009 "border=" 0 "alt=" clip_image009 "src=" http://s3.51cto.com/wyfs02/M00/77/5E/ Wkiom1zmtv2qhcxqaaaov8p_nc0358.png "" 244 "height=" 137 "/>

? Use the Chkconfig tool to adjust the startup status of individual services.

Use Chkconfig tool: (not valid until reboot)

The Chkconfig tool is similar to NTSYSV, but does not provide an interactive interface for querying or setting the default boot state of system services. Using the Chkconfig tool is more efficient when you need to set the default startup state of a service at different run levels.

Use the Chkconfig command with the "--list" option to view the default startup state of the specified system service at different run levels, and if the service name is not specified, the default startup state for all services is displayed. The 0,1,2,......,6 in the output results correspond to different runlevel.

The "on", "off" switch values allow you to set the default startup state of the service, which indicates startup, shutdown, respectively. Combined with the--level option, you can specify the corresponding runlevel. The execution format is as follows:

chkconfig--level Run Level Service name On|off

You set the cups, GPM, vncserver service to OFF by the default startup state in Run Level 3.

Steps:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" clip_image011 "border=" 0 "alt=" clip_image011 "src=" http://s3.51cto.com/wyfs02/M00/77/5D/ Wkiol1zmtc2dng7raaadf5ebyiq526.png "" 244 "height="/>

You set the default startup state of the network service in run Level 3, 5 to Enabled.

Steps:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" clip_image013 "border=" 0 "alt=" clip_image013 "src=" http://s3.51cto.com/wyfs02/M01/77/5E/ Wkiom1zmtv6ys_claaanzkjqfyi087.png "" 244 "height="/>

U Set the default startup state of the VSFTPD service in RunLevel 3, 5 to Enabled, and the remaining levels to off.

Steps:

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" clip_image015 "border=" 0 "alt=" clip_image015 "src=" http://s3.51cto.com/wyfs02/M01/77/5D/ Wkiol1zmtc6heeaxaaarlpvpgzm312.png "" 244 "height="/>

When the "--level" option is missing, you can also set the default startup state of the specified system service at different run levels, but the results of this approach are affected by the state parameters in the service script file, and there is uncertainty. Therefore, it is not recommended.

System initialization process and files

1. init Process

Similar to the use of digital tagging user accounts and group accounts, processes in a Linux system (running programs) are also marked with numbers, and each process's identity token is called a PID. In the process of booting a Linux system, "/sbin/init" is the first program loaded by the kernel, so the init process will always have a PID number of "1".

The init process is the "ancestor" of all processes that keep the entire Linux system running, so the init process is not allowed to be easily terminated. When you need to switch between different system operating states, you can send the correct execution parameters to the Init process, which is done by Init itself.

2. inittab configuration file

The Inittab file is located in the/etc directory and is the configuration file for the INIT program. When the INIT program runs, the corresponding scripts and programs in the system are started in the following configuration, as specified in the/etc/inittab file.

In the/etc/inittab file, each line is treated as a valid configuration record in addition to the comment information and blank lines that begin with the "#" sign. Use the half-width colon ":" Split between four fields in each configuration record, with the following basic format:

Id:runlevels:action:process

That

Mark : Run Level : action Type : program or Script

U when Linux is running in text mode, if the user presses the Ctrl+alt+delete hotkey combination, the system will restart after three seconds, this function is also set in the Inittab file. To disable this hotkey restart feature, you can edit the Inittab file, add a "#" number at the beginning of the "Ca::ctrlaltdel:/sbin/shutdown–t3–r Now" configuration line, and execute "init Q" command to activate the configuration (the Q option will notify the INIT process to reread the configuration file).

3. rc.sysinit script file

Rc.sysinit is the system initialization script called by the Init process, which is located in the/etc/rc.d/directory. The main completion of this script includes setting up the network, hostname, loading the file system, setting the clock, detecting the file system and a series of initialization work. The init process loads the Rc.sysinit script through the corresponding configuration in the Inittab file.

4. RC script file

The RC script is also called by the Init process, and the file is in "/ETC/RC.D/RC". The RC script enters the appropriate system runlevel by using different level parameters to load and terminate different system settings, respectively.

5. rc.local script file

The rc.local script is an additional startup control file that is located in/etc/rc.d/rc.local, which is loaded by the RC script at the last time. The rc.local script is used by the administrator to set the boot entry for itself, and the rc.local script is automatically loaded by default in RunLevel 2, 3, 4, 5. Any command actions that need to be performed automatically after the system starts can be added to the file.

System Service Control:

Service Service Name control type

Or

/etc/rc.d/init.d/ Service Name control type

[start] Stop (stop) restart (restart) reload (reload) status (View status)]

to view the operating level of the system: RunLevel

to switch the operating level of the system: Init number corresponding to the run level

? Check the memory footprint of the current system, restart and log in to character mode, and see memory consumption again.

Steps:

1. Use the grep command to filter to see the size of the system memory. :

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" clip_image017 "border=" 0 "alt=" clip_image017 "src=" http://s3.51cto.com/wyfs02/M00/77/5D/ Wkiol1zmtc-zpdckaaakzfqttqc652.png "" 244 "height="/>

2. After rebooting the system, use the grep command again to filter to see the size of the system memory. :

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" clip_image019 "border=" 0 "alt=" clip_image019 "src=" http://s3.51cto.com/wyfs02/M01/77/5D/ Wkiol1zmtc_hnz9haaak155g3po492.png "" 244 "height="/>

? Use the init command to switch to graphics mode, confirm the run level again and view the memory footprint, and compare the differences between the optimized service and the different runlevel.

Steps:

1. Enter the command "Init 5" to switch to graphics mode. :

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" clip_image021 "border=" 0 "alt=" clip_image021 "src=" http://s3.51cto.com/wyfs02/M02/77/5D/ Wkiol1zmtc-zehopaaaew3q-szm239.png "" 244 "height="/>

2. Open the pseudo terminal and use the grep command again to filter to see the size of the system memory. :

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" clip_image022 "border=" 0 "alt=" clip_image022 "src=" http://s3.51cto.com/wyfs02/M02/77/5D/ Wkiol1zmtdcck_zfaaamsfmrnl4081.png "" 244 "height="/>

Linux boot process and service control

Related Article

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.