CentOS automatically starts the desktop service after booting


After the CentOS system is booted, it usually does not start the desktop service. If you need to start it automatically, you can modify it by modifying the system running level. The following small series will be given to everyone. This section describes how to automatically start the desktop service when CentOS is powered on.


# init 3

View Run Level

# runlevel

5 3

# # The current running level of the system is ““5”, the last running level is “3””, and the conversion running level is successful.

Detailed Description

Linux systems run at a specified run level at any time, and the different runlevel programs and services are different, the work to be done and the purpose to be achieved are different. Centos sets the runlevels shown in the following table, and the system can switch between these runlevels to accomplish different tasks. Run Level Description

0 All processes will be terminated, the machine will stop in an orderly manner, and the system will be at this run level when shutting down.

1 Single User Mode. For system maintenance, only a few processes are running, and all services are not started

2 Multi-user mode. Same as run level 3, except that the Network File System (NFS) service is not started

3 Multi-user mode. Allow multiple users to log in to the system, which is the default startup level of the system

4 Leave the user-defined runlevel

5 multi-user mode, and run X-Window after system startup, give A graphical login window

6 All processes are terminated, the system is restarted

1. If the system enters the character login CentOS interface after startup, the default running level of the system is 3; After the system starts, enter the graphical login CentOS interface, indicating that the system default running level is 5.

2. If the user has started the character CentOS interface, you can use the following command to enter the graphical CentOS interface:

$ startx &

Run level view and switch

Users can use the following commands to view the running level of the current system. Runlevel users can use the following command to switch the run level init [0123456Ss], which is followed by a parameter in the init command, which is the run level to be switched to. Run level code, such as:

Use the init 0 command to switch to run level 0, that is, shut down (do not set initdefault to 0)

Use the init 1 command to switch to run level 1. Go into single-user mode

Switch to runlevel 6 with the init 6 command, ie reboot (do not set initdefault to 6)

You can also use the te linit command in CentOS The te linit command is a symbolic link to the init command.

Let's look at an example of using the runlevel and init commands:

# # Display the current running level of the system

# runlevel

N 3

# # The current running level of the system is “3”, the last running level (represented by “N”)

# init 2

# # 执行“init 2&rdquo After the command, the corresponding stop start service information will be displayed in the system console.

# runlevel

3 2

# # The current running level of the system is already “2”, The last run level was “3”, the conversion run level was successful.

The above is the introduction of the method of automatically starting the desktop service when CentOS starts. If you want to close the desktop service, you can change the running level of inidefault in /etc/inittab to 2 or 3 to close the desktop. The service has started.

Copyright © Windows knowledge All Rights Reserved