Linux System Management Preliminary (vii) system service management, Chkconfig and SYSTEMD editing

Source: Internet
Author: User

Linux system itself contains a lot of services, CentOS6 before the system services with SYSV control, CENTOS7 changed to SYSTEMD control

One, Chkconfig service management mechanism

In short, chkconfig is the tool that CentOS6 used to control system services,
Examples of common methods
Chkconfig--list #列出所有的系统服务.
Chkconfig--add httpd #增加httpd服务.
Chkconfig--del httpd #删除httpd服务.
Chkconfig--level httpd 2345 on #设置httpd在运行级别为2, 3, 4, 5 are on (open) state.
Chkconfig--list mysqld #列出mysqld服务设置情况.
Chkconfig--level mysqld on #设定mysqld在等级3和5为开机运行服务,--level 35 means that the operation is performed only on levels 3 and 5, on indicates start, off table

Some of the services that are started when the system is powered on are stored in the/etc/init.d/directory. We can put the services that need to boot up in this directory and then use Chkconfig to manage.

1. List Chkconfig Management Services

Chkconfig
Chkconfig--list

2. Set up and close each service at different levels

Here first hint at the level of concept, hard to remember the concept, anyway this CentOS7 later version will not be used, we summarize some key words to facilitate understanding:
0 is the shutdown,
1 is a single user, that is, we have previously modified the root account password mode,
2 is multi-user mode, but one NFS service is less than the 3 mode
3 is a multi-user command-line mode, most commonly used
4 is the retention level temporarily useless,
5 is the graphics mode,
6 is the reboot,

Close Network Service

Chkconfig Network off

K Open Network Service

Chkconfig Network on

Turn off the network service at level 5th

Chkconfig--level 5 Network off

Customize a service and add it to chkconfig management
The first custom script will be the same format as the original network and Netconsole service script.
Let's take a look at the script.

Vi/etc/init.d/network

The part of the red box is a must.

We can make a copy of the network and do the experiment.

CP Network Test

Then we add the order to Chkconfig management.

Chkconfig--add Test #注意两个减号

Chkconfig--del Test

With the version update, Chkconfig is already in the past ...

Second, SYSTEMD service management mechanism ∴

View Systemd Managed Services

Systemctl List-unit-all-type=service #查看所有服务
Systemctl list-units--type=service #查看所有已经启动的服务


There are three options for the service, load, ACTIVE, SUB, see:

Operation commands for a single service:

Systemctl Enable Crond # #设置开机启动crond服务或工具
Systemctl Disable Crond # #设置关闭开机启动crond服务或工具
Systemctl Status Crond # #查看crond服务当前状态, such as whether to run
Systemctl Stop Crond # #停止crond服务是, but the boot will still run
Systemctl Start Crond # #开启crond服务
Systemctl Restart Crond # #重启crond服务
Systemctl is-enabled Crond # #检查crond服务是否开机启动

Linux System Management Preliminary (vii) system service management, Chkconfig and SYSTEMD editing

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.