Linux Chkconfig installation and use of the detailed

Source: Internet
Author: User

Chkconfig Installation

In the beginning, because of the raspbian reason, the system is not brought chkconfig this command,

root@raspberrypi:~# Chkconfig
-bash:chkconfig:command not found

So you have to install it manually.

Installation is very simple Apt-get install chkconfig can,

The installation process is as follows:

root@raspberrypi:~# apt-get Install chkconfig
Reading Package lists ... Done
Building Dependency tree      
Reading state information ... Done
The following NEW packages is installed:
  chkconfig
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 9766 B of archives.
After this operation, 59.4 KB of additional disk space would be used.
Get:1 http://mirrors.ustc.edu.cn/raspbian/raspbian/jessie/main chkconfig all 11.4.54.60.1debian1 [9766 B]
fetched 9766 B in 0s (20.1 kb/s)
Selecting previously unselected package.
(Reading database ...) 120673 files and directories currently installed.)
Preparing to unpack .../chkconfig_11.4.54.60.1debian1_all.deb ...
Unpacking Chkconfig (11.4.54.60.1debian1) ...
Processing triggers for man-db (2.7.0.2-5) ...
Setting up Chkconfig (11.4.54.60.1debian1) ...
uses the Chkconfig
below is the command Help for Chkconfig

Use syntax:
Chkconfig [–add][–del][–list][System Services] or Chkconfig [–level < rank code >][system Services][on/off/reset]

Chkconfig Displays the usage when no parameters are running. If you add a service name, check to see if the service is starting at the current run level. Returns true if it is, or false. If On,off or reset is specified after the service name, CHKCONFI changes the startup information for the specified service. On and off means that the service is started and stopped, and reset refers to resetting the service's startup information, regardless of what the initialization script for the problem specifies. On and off switches, the system defaults to run-level 3,4,5 only, but reset can be valid for all run levels.

Parameter usage:

–add adds the specified system service, allows the chkconfig instruction to manage it, and adds the relevant data to the system-initiated narrative file.
–del deletes the specified system service, is no longer managed by the Chkconfig command, and deletes the relevant data in the system-initiated narration file.
–level < grade code > specifies which execution level the system service should be opened or closed.
Level 0 means: the shutdown
Level 1: Single user mode
Level 2 means: Multi-user command-line mode with no network connection
Level 3 means: Multi-user command-line mode with network connections
Level 4 indicates: Not available
Level 5 means: Multi-user mode with graphical interface
Level 6 indicates: reboot

Disable a service on the boot

Take MiniDLNA, for example,

Let's take a look at the current operation of the MiniDLNA service.

root@raspberrypi:~# Chkconfig-l | grep Mini
MiniDLNA 0:off 1:off 2:on 3:on 4:on 5:on 6:off
All disabled from level 2–5.
Using the command chkconfig--level 2345 MiniDLNA off,

And in the query once again service status, as follows:

root@raspberrypi:~# chkconfig--level 2345 MiniDLNA off
root@raspberrypi:~# Chkconfig-l | grep Mini
MiniDLNA 0:off 1:off 2:off 3:off 4:off 5:off 6:off

In order to save the raspberry Pie 2b poor 512mb memory, I also conveniently disabled the FTP and MySQL service.

Afterwards, reboot, view service status

Because I was using the LNMP one-click installation of the packaging environment,

So I use the LNMP status and Lnmp pureftpd status to view the status of the service.
Look at the memory use, and really less use a few 10 trillion, hey.

For example, Random.init contains three lines:
# chkconfig:2345 20 80
# description:saves and restores system entropy pool for \
# higher quality random number generation.

Use Example:
chkconfig--list        #列出所有的系统服务
Chkconfig- -add httpd        #增加httpd服务
Chkconfig--del httpd         #删除httpd服务
chkconfig--level httpd 2345 on        # Set the httpd status on (open)
Chkconfig--list        When the run level is 2, 3, 4, 5 #列出系统所有的服务启动情况
Chkconfig--list mysqld        #列出mysqld服务设置情况
Chkconfig--level-mysqld on        #设定mysqld在等级3和5为开机运行服务,--level 35 indicates that the operation is performed only on levels 3 and 5, on means start, and off is off
Chkconfig mysqld on        #设定mysqld在各等级为on, "Each level" includes 2, 3, 4, 5 levels

How to add a service:
1. Service scripts must be stored in the/etc/ini.d/directory;
2.chkconfig--add servicename
    Add this service in the Chkconfig tool Services list, at which point the service is given a k/s entry in the/ETC/RC.D/RCN.D;
3.chkconfig--level mysqld on
    Modify the default boot level for the service.

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.