Linux Set up service boot command method

Source: Internet
Author: User
Tags iptables

Mode one: NTSYSV

Similar to the Msconfig tool in Windows, which is used to set whether a service is started randomly. You can use NTSYSV to start or turn off services managed by XINETD, and you can use NTSYSV to configure the run level. Services managed by XINETD will be immediately affected by NTSYSV, while other services would not take effect immediately. You must use the service xxxxx Stop/start/restart command to stop/run/restart a service. (Replace the xxxxxx with the name of the service you want to stop), such as

The code is as follows Copy Code
#ntsysv
#service Network Retart
"Use of Service: Service name (Start/restart/stop/status)"

I have encountered the problem:
Once want to use the command #serverce iptables start firewall, but is unable to start, and finally used the NTSYSV command, select the iptables, running service iptables start can be started normally.

Mode two: Chkconfig

Chkconfig services that are started when you manage system initialization. The Chkconfig command can be used to activate or deactivate a service, or it can be used to set up a service to start randomly. However, the Chkconfig directive does not automatically prohibit or activate a service immediately. It simply changes the symbolic connection. The
usage instructions are as follows:
Function Description: Check, set up the system of various services.
Syntax: Chkconfig
[--add][--del][--list][system service] or chkconfig[--level< rank code >][system service][on/off/reset]
Parameters:
–add adds the specified system service, allows the chkconfig instruction to manage it, and adds the relevant data to the system-initiated narrative file. The
–del deletes the specified system service, is no longer managed by the chkconfig instruction, and deletes the relevant data in the system-initiated narration file. The
–level< rank code > Specifies which execution level the read system service should be opened or closed
The 1:chkconfig command can also be used to activate and deactivate a service. The chkconfig–list command displays a list of system services and whether these services have been started (on) or stopped (off) at run level 0 through 6.

The code is as follows Copy Code
Chkconfig–add SMB #增加smb服务
Chkconfig–list | grep SMB
Chkconfig–list SMB
SMB 0:off 1:off 2:on 3:on 4:on 5:on

2:chkconfig can also be used to set a service to be started or deactivated at a specified run level. For example, to deactivate the Samba service at run Level 3 and 5, use the following command:
Chkconfig–level SMB off
3: Services managed by XINETD will immediately be chkconfig affected. For example, if XINETD is running, and finger is disabled, and after the chkconfig finger on command is executed, finger does not have to manually restart xinetd to be enabled immediately. Changes to other services will not take effect immediately after the use of chkconfig. You must use the service servicename Start/stop/restart command to restart services

mode three: use the service configuration to set Samba's self startup, that is, under the graphical interface, this method is slightly.
Summary: The use of NTSYSV and chkconfig can make the services managed by xinetd effective immediately, while other services are required to run
#service xxxx Restart to take effect.

Method Four:

Enter the #setup command into the System Services menu, select the service you want to start, such as httpd, and then restart the machine or/etc/rc.d./init.d/httpd
Start

Method Five:

Second type)
Put the launch command into the/etc/rc.d/rc.local file so that you can start the service automatically every time you start, for example, for Apache, after compiling Apache, you will generate Apachectl files in the bin under the installation directory, which is a startup script, We just need to add this command to rc.local.
(SuSE has no rc.local.) SuSE can define their own scripts, and if you want to run your own scripts before and after switching to the run level, you can create the respective:

  code is as follows copy code

/etc/ Init.d/before.local
/etc/init.d/after.local)
echo/usr/local/apache/bin/apachectl>>/etc/rc.d/ Rc.local, the
set up a service to start automatically is to add some scripts similar to the following in rc.local:
#sshd
/usr/local/sbin/sshd

#proftpd
/usr/ LOCAL/SBIN/PROFTPD

#apache
/home/apache/bin/apachectl start

#mysql
/home/mysql/bin/safe_ Mysqld--port=3306

#start oracle8i Listener the
su-oracle-c ' lsnrctl start '

#start oracle8i su-oracle-c ' Dbstart '

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.