Linux chkconfig command usage

Source: Internet
Author: User

In linux, The chkconfig command is mainly used to update (start or stop) and query the running level information of the system service. Keep in mind that chkconfig does not automatically disable or activate a service immediately. It simply changes the symbolic connection. I will introduce it to you in detail for your reference.

Syntax:

Chkconfig [-- add] [-- del] [-- list] [System Service] Or chkconfig [-- level <level code>] [System Service] [on/off/reset]

Each service managed by chkconfig needs to add two or more lines of comments to the script under/etc/rc. d/init. d.
The first line tells chkconfig the default startup running level and the priority of start and stop. If a service is not started at any running level by default, use-to replace the running level

The usage of chkconfig is displayed when no parameter is available. If the service name is added, check whether the service is started at the current running level. If yes, true is returned; otherwise, false is returned. If on, off, or reset is specified after the service name, chkconfi changes the startup information of the specified service. On and off indicate that the service is started and stopped, and reset indicates that the Service Startup information is reset, no matter what is specified by the problematic initialization script. On and off switches. By default, the system is only valid for 3, 4, and 5 running levels, but the reset can be valid for all running levels.

Parameter usage:
-Add adds the specified system service, enables the chkconfig command to manage it, and adds relevant data in the system startup description file.
-Del: deletes the specified system service. It is no longer managed by the chkconfig command, and relevant data is also deleted in the description file started by the system.
-Level <level code> specifies the execution level of the read system service.
Level 0: Shutdown
Level 1: Single User Mode
Level 2: multi-user command line mode without network connection
Level 3: multi-user command line mode with network connection
Level 4: unavailable
Level 5: multi-user mode with graphic interface
Level 6: restart
It should be noted that the level option can specify the running level to be viewed, not necessarily the current running level. For each running level, only one startup script or stop script is allowed. When you switch to the running level, init does not restart the started service or stop the stopped service again.

Chkconfig-list [name]: displays the running status information (on or off) of all running-level system services ). If the name is specified, only the status of the specified service at different running levels is displayed.
Chkconfig-add name: adds a new service. Chkconfig ensures that each running level has a startup (S) or kill (K) entry. If the init script is missing, it is automatically created from the default init script.
Chkconfig-del name: Delete the service and delete the connection from/etc/rc [0-6]. d.
Chkconfig [-- level levels] name: sets whether a service is started, stopped, or reset at the specified running level.

Run-level files:
Each service managed by chkconfig needs to add two or more lines of comments to the script in the corresponding init. d. The first line tells chkconfig the default startup running level and the priority of start and stop. If a service is not started at any running level by default, use-to replace the running level. The second line describes the service and can be annotated across rows.
For example, random. init contains three rows:
# Chkconfig: 2345 20 80
# Description: Saves and restores system entropy pool
# Higher quality random number generation.

Example:

Chkconfig-list # list all system services
Chkconfig-add httpd # add httpd service
Chkconfig-del httpd # Delete the httpd service
Chkconfig-level httpd 2345 on # Sets httpd to on when the running level is 2, 3, 4, or 5.
Chkconfig-list # list all system startup statuses
Chkconfig-list mysqld # list mysqld service settings
Chkconfig-level 35 mysqld on # Set mysqld to run at level 3 and 5.-level 35 indicates that the operation is only executed at level 3 and 5, on indicates that the operation is started, and off indicates that the operation is disabled.
Chkconfig mysqld on # Set mysqld to on at each level. "Each level" includes 2, 3, 4, and 5 levels.

How to add a service:

1. The service script must be stored in the/etc/ini. d/directory;
2. chkconfig-add servicename
Add this service to the chkconfig tool service list. In this case, the service will be assigned a K/S entry in/etc/rc. d/rcN. d;
3. chkconfig-level 35 mysqld on
Modify the default service start level

Example (set service startup)

Chkconfig
Chkconfig is used to manage the services started during system initialization. The Chkconfig command can be used to activate or stop a service, or set to enable a service to start at random. However, the chkconfig command does not automatically disable or activate a service immediately. It simply changes the symbolic connection.
The usage instructions are as follows:
Function Description: Check and set various services of the system.
Syntax: chkconfig
[-- Add] [-- del] [-- list] [System Service] Or chkconfig [-- level <level code>] [System Service] [on/off/reset]
Parameters:
-Add adds the specified system service, enables the chkconfig command to manage it, and adds relevant data in the system startup description file.
-Del: deletes the specified system service. It is no longer managed by the chkconfig command, and relevant data is also deleted in the description file started by the system.
-Level <level code> specifies the execution level of the read System Service
1: The chkconfig command can also be used to activate and remove services. The chkconfig-list command displays the list of system services, and whether these services have been started (on) or stopped (off) in the running level from 0 to 6 ).
Chkconfig-add smb # add smb service
Chkconfig-list | grep smb
Chkconfig-list smb
Smb 0: off 1: off 2: on 3: on 4: on 5: on 6: off
2: chkconfig can also be used to set whether a service is started or stopped at a specified running level. For example, to stop the samba service at runtime Level 3 and 5, run the following command:
Chkconfig-level 35 smb off
3: services managed by xinetd are immediately affected by chkconfig. For example, if xinetd is running and finger is disabled, after the chkconfig finger on command is executed, finger does not have to manually restart xinetd to be enabled immediately. Changes to other services do not take effect immediately after chkconfig is used. You must use the service servicename start/stop/restart command to restart the service.


Disable unnecessary services in Linux

Chkconfig -- list display.
Chkconfig [service] off closes one of the services.
The name of the waiting process.
Amd: automatically installs NFS (Network File System) Guard processes.
Apmd: advanced power management.
Arpwatch: records logs and constructs an ethernet address and IP address pair database seen on the LAN interface.
Autofs: automatically installs the management process automount, which is related to NFS and relies on NIS.
Bootparamd: boot parameter server that provides information required for booting a diskless workstation on the LAN.
Crond: scheduled tasks in Linux.
Dhcpd: Start a DHCP (Dynamic IP Address Allocation) server.
Gated: waiting for the gateway route. Use the dynamic OSPF route selection protocol.
Httpd: WEB server.
Inetd: supports core waiting programs for multiple network services.
Innd: Usenet news server.
Linuxconf: allows you to use a local WEB server as a user interface to configure machines.
Lpd: Print Server.
Mars-nwe: the mars-nwe file and the printing server for Novell.
Mcserv: Midnight command file server.
Named: DNS server.
Netfs: Install NFS, Samba, and NetWare network file systems.
Network: Activate the script program with configured network interfaces.
Nfs: Enable the NFS service.
Nscd: nscd (Name
Switch Cache daemon) server, used for an NIS Support Service, which caches user passwords and forms a membership relationship.
Portmap: RPC
Portmap manager, similar to inetd, manages RPC-based connections.
Postgresql: An SQL database server.
Routed: Route waiting process. Use Dynamic RIP routing to select the protocol.
Rstatd: A waiting program for other machines on the LAN to collect and provide system information.
Ruserd: remote user location service, an RPC-based service that provides user information about a machine log currently recorded on the LAN.
Rwalld: activates the rpc. rwall service process, which is an RPC-based service that allows users to write messages to each terminal registered to the LAN machine.
Rwhod: activates the rwhod service process. It supports rwho and ruptime services of the LAN.
Sendmail: The Mail Server sendmail.
Smb: Samba file sharing/printing service.
Snmpd: processes are managed on a local simple network.
Squid: the squid of the active proxy server.
Syslog: a script that enables syslog and klogd system logs to wait for processes during system boot.
Xfs: X
The Window server provides a font set for local and remote X servers.
Xntpd: Network Time Server.
Ypbind: activates the ypbind service process for the NIS (Network Information System) client.
Yppasswdd: NIS Password server.
Ypserv: NIS master server.
Gpm: Specifies the mouse.
Identd: AUTH service, which is similar to finger in providing user information.

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.