How to boot the CentOS Setup program

Source: Internet
Author: User
Tags stop script

Centoslinux

in the case of CentOS or redhat other systems, the system will not start automatically after installation, such as httpd, mysqld, postfix, etc., if the service is installed later. even if the service is started manually by/etc/init.d/mysqld start, the service will not start automatically as long as the server restarts.

At this time, we need to set up after installation, let the system automatically start these services, to avoid unnecessary loss and trouble.

In fact, the command is very simple, use chkconfig can. For example, to set the mysqld to boot automatically:

#chkconfig mysqld on

In the same vein, to cancel a service auto-start, you only need to change the last parameter "on" to "Off". For example, to cancel the auto-start of postfix:

#chkconfig postfix off

It is important to note that if the service has not been added to the Chkconfig list, it is now necessary to add it using the –add parameter:

#chkconfig--add Postfix

If you want to query all currently started services automatically, you can enter:

#chkconfig--list

But it shows too many things and looks dizzy. What if you want to see only the services you specify? This time only need to add the service name after the "–list", such as to see if the HTTPD service is automatically started, enter:

#chkconfig--list httpd

The result of this time output:

httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

When the 0~6 is off, the HTTPD service does not start automatically when the system starts. After we enter Chkconfig httpd on, check again that the output is changed to:

httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

This time the 2~5 is on, which indicates that it will start automatically.

#让httpd stop at run level when machine is started

[Email protected] etc]# chkconfig--level 345 httpd off

[Email protected] etc]# chkconfig--list |grep httpd

httpd 0: Off 1: Off 2: Off 3: Off 4: off 5: off 6: Off

#让httpd start at run level when machine is started

[Email protected] etc]# chkconfig--level 345 httpd on

[Email protected] etc]# chkconfig--list |grep httpd

httpd 0: Off 1: Off 2: Off 3: Enable 4: Enable 5: Enable 6: Off

Ps-ef can be used to see what programs are running.

Delete Service

Rm/etc/init.d/servername

----------------------------------------------------------------------------------------

1. Add the written startup script to the directory/etc/rc.d/init.d/, then use the command chkconfig to set the boot up.
For example: We write the httpd script and put it into the/etc/rc.d/init.d/directory, using

1 Chkconfig--add httpd

2 Chkconfig httpd on

The command is set to boot.

------------------------------------------------------------------------------------------

Chkconfig command

Function Description: Check, set the system of various services.

Syntax: chkconfig [--add][--del][--list][system service] or
Chkconfig [--level< Class Code >][system service][on/off/reset]

Note: This is a program developed by the Redhat company in accordance with the GPL rules, which can query what system services the operating system performs in each execution level (RunLevel), including various daemon.

The Linux OS divides the operating environment into the following 7 levels:


0: Boot (please do not switch to this level)
1: Text interface for single user mode
2: Multi-person user mode text interface, does not have the network File system (NFS) function
3: Multi-person user mode text interface, with Network File system (NFS) function
4: Some distributions of Linux use this level to enter the X Windows system
5: Some distributions of Linux use this level to enter the X Windows system
6: Restart

Parameter:--add new system service specified
--del Delete the specified system service
--LEVEL specifies in which execution level the system service is to be turned on or off
--list List all system services and rank codes currently available from the CHKCONFIG directive
On/off/reset on/off/reset the system service at the specified execution registration

The Chkconfig command is primarily used to update (start or stop) and query run-level information for system services. Keep in mind that Chkconfig does not immediately automatically disable or activate a service, it simply changes the symbolic connection.

Grammar:

Chkconfig--list [Name]
Chkconfig--add Name
Chkconfig--del Name
Chkconfig [--level levels] name <on|off|reset>
Chkconfig [--level levels] Name

Chkconfig displays usage when no parameters are run. If the service name is added, check that the service is started at the current run level. If yes, returns TRUE, otherwise false is returned. If On,off or reset is specified after the service name, CHKCONFI will change the startup information for the specified service. On and off refers to the service being started and stopped, and reset refers to the boot information of the reset service, regardless of what is specified by the problematic initialization script. On and off switches, the system is only valid for run-level 3,4,5 by default, but reset can be valid for all run levels.

The--level option allows you to specify the run level you want to view, not necessarily the current run level.

It is necessary to note that for each run level, there can be only one startup script or stop script. When you switch the run level, Init does not restart the service that is already started, nor does it stop the service that has stopped.

Chkconfig--list: Displays the running status information (on or off) of all run-level system services. If name is specified, only the state of the specified service at a different run level is displayed.

Chkconfig--add Name: Add a new service. Chkconfig ensure that each run level has a start (S) or Kill (K) entry. If one is missing, it is automatically created from the default init script.

Chkconfig--del Name: Deletes the service and removes the associated symbolic connection from the/ETC/RC[0-6].D.

Chkconfig [--level levels] name <on|off|reset>: Sets whether a service is started, stopped, or reset at the specified run level. For example, to stop the NFS service at the 3,4,5 run level, the command is as follows:

Chkconfig--level 345 NFS Off

Run-level files:

Each service managed by Chkconfig needs to add two or more lines of comments to the script under the corresponding INIT.D. The first line tells Chkconfig the run level of the default startup and the priority of start and stop. If a service does not start at any run level by default, use-instead of run-level. The second line describes the service and can be annotated with/across lines.
For example, Random.init contains three rows:
# chkconfig:2345 20 80
# description:saves and restores system entropy pool for/
# higher quality random number generation.

Add a description of the operational level concept of the Linux system:
Linux has a variety of operating levels, the common is multi-user 2,3,4,5, many people know that 5 is the level of running X-windows, and 0 is shutdown. Changes to the run level can be toggled with the init command. For example, if you want to maintain the system into a single-user state, you can use INIT1 to switch. During the switching process of Linux running level, the system will automatically find files corresponding to the/etc/rc[0-6].d of K and S under the directory of Run level, and execute these scripts in the following numerical order. The maintenance of these scripts is a tedious thing, Linux provides the chkconfig command to update and query system services at different run levels.

Example:

1. View the status of each service in various levels of execution:
$chkconfig--list

2. List the startup status of the system service VSFTPD at each execution level:
$chkconfig--list vsftpd

3. At execution level 3, 5 o'clock, turn off the VSFTPD system service:
$chkconfig--level vsftpd off

4. When performing level 2,3,5, turn on the VSFTPD system service:
$chkconfig--level 235 vsftpd on

5. Close some services that you do not need
If you do not have a printer:
Chkconfig--level 235 Cups off
If you do not have a LAN:
Chkconfig--level 235 SMB off
If you do not require a remote user to log on:
Chkconfig--level 235 sshd off
If you do not need a scheduled task:
Chkconfig--level 235 Crond off
If you do not need to add new hardware:
Chkconfig--level 235 Kudzu off

Transferred from: http://www.cnblogs.com/phpnow/archive/2012/07/14/2591849.html

How to boot the CentOS Setup program

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.