Linux chkconfig Command Detailed

Source: Internet
Author: User

First, Introduction

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.

Second, installation & start-up
[Email protected]:~$ sudo apt-get install chkconfig
Three, grammar & parameters
 [email protected]:~$ chkconfig-- helpusage:chkconfig-a|--allservices (together with - l:show all services) chkconfig-t|-- terse [names] (shows the links) chkconfig-e|--     edit [Names] (Configure services) chkconfig-s|-- set [name State] ... (Configure services) Chkconfig-l|--list [-- deps] [names] (shows the links) chkconfig-c|-- check name [ State] (check state) chkconfig-a|-- Add [Names] (runs Insserv) Chkconfig-d|--del [names] (runs Insserv- r) Ch kconfig-h|-- Help (print usage) Chkconfig-f|--force ... (Call Insserv with- f) chkconfig [name] same as Chkconfig- t chkconfig name State ... same as Chkconfig- s name state[email protected]:~$           

Chkconfig commonly used parameters are-l,-A,-s,-D if no input parameters, chkconfig default Parameters-A, display all the previous services and marked on or off status. If you add the service name, which is equivalent to using the-t parameter, 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.

    • Displays the health status information (on or off) for all run-level system services.
      Chkconfig-l | [--list] [Names]
      If names is specified, only the state of the specified service at a different run level is displayed.
    • Add a new self-starting service
      chkconfig-a | [--add] [Names]

      Before you add a self-starting service, you must ensure that the appropriate service scripts are in the/etc/init.d/directory. 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.

    • Modifying self-starting services
      Chkconfig-s | [--edit] [Names State]

      The state can be on, off, and Linux operating environment level (0123456), and may be enforced by using-f if the dependent relationship causes the execution to fail during the operation.

    • To delete a self-starting service
      Chkconfig-d|--del   [Names]

      After the service is deleted, the files of the server under the corresponding/etc/rc[0-6].d/folder are also deleted accordingly.

Iv. Practice
  1. view MySQL's specific self-boot configuration
     [email protected]:~$ chkconfig-l mysql 
     mysql 0:off 1:of F 2:off 3:off 4:off 5:off 6:off 
  2. Add the MySQL service so that it can start with the system boot
     [email protected]:~$ chkconfig-a mysql 

    Ubuntu 12.04 Executes the command returns an error   /sbin/insserv:no such file or directory  we can see that this is probably caused by a lack of files/sbin/insserv. You can first find the file location for the next insserv

     [email protected]:~$ whereis  Insservinsserv:/bin/insserv/etc/ Insserv.conf/etc/insserv/usr/lib/insserv/usr/share/insserv/usr/share/man/man8/insserv.8  .gz[email  protected]:~$   

    Can find the LL command we find one by one, found that the Insserv file really exists in the  /usr/lib/insserv  directory

     [ email protected]:~$ ll/bin/ insservlrwxrwxrwx 1 root root Oct 13:49/bin/insserv-/usr/lib/insserv/i nsserv*  [email protected]:~$   

    For this, we can create a/usr/lib/insserv/insserv soft connection in the/sbin directory

     [email protected]:~$ ln-s/usr/lib/insserv/insserv/sbin/insserv 

    We can use the CHKCONFIG-A command.

     mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off 
  3. Modify the MySQL service so that it can start with the system boot
    [Email protected]:~$ chkconfig-e MySQL
    MySQL off

    Or

    [Email protected]:~$ chkconfig-s MySQL on
  4. Remove MySQL self-boot service
    [Email protected]:~$ chkconfig-d MySQL
  5. Configure MySQL self-boot service Linux run level 2345
    [Email protected]:~$ chkconfig-sf MySQL 2345
  6. Manually configure MySQL self-boot service Linux run level 2345
    [Email protected]:~$ ln-s/etc/init.d/mysql/etc/rc.d/rc2.d/s100mysql[email protected]:~$ ln-s/etc/init.d/mysql/ etc/rc.d/rc3.d/s100mysql[email protected]:~$ ln-s/etc/init.d/mysql/etc/rc.d/rc4.d/S100mysql[email protected]:~$ ln-s/etc/init.d/mysql/etc/rc.d/rc5.d/s100mysql  
V. Expansion
    • 7 different operating levels of Linux (normally 3 or 5 in normal cases)
      • 0: System shutdown status, the system default operation level cannot be set to 0, otherwise it will not start normally, the machine shuts down.
      • 1: Single user working status, root privileges, for system maintenance, prohibit remote login, just like Windows security mode login.
      • 2: Multi-user status, no NFS support.
      • 3: Full multi-user mode, NFS, login to console command line mode.
      • 4: The system is not used, reserved for general use, in some special cases you can use it to do some things. For example, you can switch to this mode to do some setup when your laptop's battery is running out.
      • 5:x11 console, after landing into the graphical GUI mode, Xwindow system.
      • 6: The system shuts down gracefully and restarts, the default runlevel cannot be set to 6, otherwise it will not start normally. Running the INIT6 machine will restart.

Linux chkconfig Command Detailed

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.