Linux Run Level

Source: Internet
Author: User

This article was also published in HTTPS://GITHUB.COM/ZHANGYACHEN/ZHANGYACHEN.GITHUB.IO/ISSUES/47

Description of Run level at different run levels

RunLevel 0: System down state, system default RunLevel cannot be set to 0, otherwise it will not start normally
RunLevel 1: Single User working status, root privilege, for system maintenance, remote login Forbidden
RunLevel 2: Multi-user State (no NFS,NFS is a network file system)
RunLevel 3: Full multiuser State (with NFS), enter console command line mode after login
Run Level 4: System not used, reserved
Run level 5:x11 console, login to GUI mode
RunLevel 6: The system shuts down gracefully and restarts, the default runlevel cannot be set to 6, otherwise it will not start normally

Note: Under the Ubuntu system, run level 2-5 provides the same service, that is, 2-5 levels are not different, so Ubuntu system 0 means shutdown, 1 means maintenance mode, 2-5 represents the GUI interface of the system, 6 indicates a reboot system.

To modify the default run level

If you want to modify the default run level, modify the/etc/inittab file. (The Ubuntu system does not have a/etc/inittab file by default, and the default runlevel is specified in the/etc/init/rc-sysinit.conf file.) )

id:3:initdefault:

Change the number to the desired runlevel.

The difference between the different run levels is the difference between the services that the system is starting by default. For example, run Level 1 shuts down network services, and run Level 3 does not start the X graphical interface service by default, while RunLevel 5 starts by default.

RunLevel command
[[email protected] ~]# runlevelN 3

Use the RunLevel command to display the previous and current runlevel, separated by space characters, and N if there were no previous runlevel. For example, the system default run level is 2, and the user does not switch the RunLevel, then the system is displayed as N 2 after running the RunLevel command. If the current runlevel is 2 and the user switches to run level 3 with Init 3, then the RunLevel command is displayed as 2 3.

RCN.D Directory and INIT.D directory

Each runlevel corresponds to a rcn.d directory in/etc, and the range of n is 0-6. When the system starts, the service under the corresponding RCN.D directory is executed according to the default run level. For administrative convenience, all services in this directory are actually soft links to the corresponding script files in the/ETC/INIT.D directory. The startup and shutdown functions of the service are completed by the script file under the INIT.D directory.
The format of the file in the RCN.D directory is: [Sk]nnname. s means to start the service, K to close the service, nn for the start sequence number, the smallest number to start first, and the largest number to be started. Name indicates the service name.

[[email protected] etc]# CD rc3.d/[[email protected] rc3.d]# lsk01smartd k15httpd K69RPCSVCGSSD K76ypbind k89rdisc s02lvm2-monitor s12rsyslog s23networkmanager s26acpid s64mysqld S90    CRONDK02ODDJOBD k30spice-vdagentd k73winbind k84wpa_supplicant k92pppoe-server s08ip6tables S13cpuspeed           S24nfslock S26haldaemon s80postfix S95atdk05wdaemon k50dnsmasq k74ntpd k86cgred        K95firstboot s08iptables s13irqbalance s24rpcgssd s26udev-post s82abrt-ccpp S97rhnsdk10psacct K50kdump k75cgconfig k87restorecond k95rdma s10network s13rpcbind S25blk-availab ility s28autofs s82abrtd s97rhsmcertdk10saslauthd k60nfs k75ntpdate K88SSSD k99rn  GD s11auditd s15mdmonitor s25cups s50bluetooth s84php-fpm S99certmongerk15htcacheclean K61NFS-RDMA k75qUOTA_NLD k89netconsole s01sysstat s11portreserve s22messagebus s25netfs s55sshd S85nginx S99local
[[email protected] rc0.d]# lltotal 0lrwxrwxrwx. 1 root root 20 Apr  5 18:20 K01certmonger -> ../init.d/certmongerlrwxrwxrwx. 1 root root 16 Apr  5 18:23 K01smartd -> ../init.d/smartdlrwxrwxrwx. 1 root root 17 Apr  5 18:20 K02oddjobd -> ../init.d/oddjobdlrwxrwxrwx. 1 root root 19 Apr  5 18:20 K02rhsmcertd -> ../init.d/rhsmcertdlrwxrwxrwx. 1 root root 15 Apr  5 18:19 K03rhnsd -> ../init.d/rhnsdlrwxrwxrwx. 1 root root 13 Apr  5 18:20 K05atd -> ../init.d/atdlrwxrwxrwx. 1 root root 17 Apr  5 18:25 K05wdaemon -> ../init.d/wdaemon

We note that the Nginx service is started by default at the run level of 3.

[[email protected] rc3.d]# ls | grep nginxS85nginx

If you do not want to start the Nginx machine, enter the following command:

[[email protected] rc3.d]# chkconfig nginx off

The Nginx service does not start automatically when it is powered on.

[[email protected] rc3.d]# ls | grep nginxK15nginx
Chkconfig

Run-level information used to update (start or stop) and query system services

chkconfig [--list] [--type type][name]chkconfig --add namechkconfig --del namechkconfig --override namechkconfig [--level levels] [--type type] name <on|off|reset|resetpriorities>chkconfig [--level levels] [--type type] name

For specific usage see http://roclinux.cn/?p=51 orman chkconfig

Reference: http://blog.csdn.net/luomoweilan/article/details/20290165

Linux Run Level

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.