In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to set the running level and goals of Linux", so the editor summarizes the following contents, detailed contents, clear steps, and certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to set the running level and goals of Linux" article.
Run-level Run Level everyone knows that Windows has a safe mode, which is the minimum mode of Windows. Compared with the normal mode, safe mode allows users to better detect the system and fix errors. The run level of Linux is a similar mechanism, and different run levels have different functions:
We usually use levels 3 and 5, the general server does not need to install a graphical interface, and need to support remote connections, so the run level will choose 3; personal computers generally need GUI, so will choose run level 5.
To see the runlevel of the current system, you can use commands.
# runlevel
N 5
The above results indicate that the current runlevel is 5. You can use the command to switch between different levels
# init [run level]
For example, it is currently running at level 3, which is a multi-user character interface. To start the GUI graphical interface, you only need to type init 5.
Although the runlevel can be switched in real time, if you want to change the default runlevel at system startup, you can also modify the / etc/inittab file in CentOS 5 and 6 to configure it.
System initialization process systemd vs. Init before CentOS 7, the system initialization process is init, its PID is 1, the initialization process is the first program executed by the system, and all other processes are its child processes, so the command we use to switch runlevel is init, and the default runlevel configuration file for system startup is / etc/inittab.
Starting with CentOS 7, the system initialization process uses a brand new systemd. As can be seen from its name, it is a service that runs automatically in the background by the system. Compared with init, systemd has some obvious advantages:
1) systemd uses a concurrent startup mechanism when the system starts, while init starts each service sequentially. In fact, many services do not have dependencies and do not need to wait in turn. In the early days of Linux, the CPU of computers was single-core and could only handle one task at a time, so the design of init had its rationality. However, with the development of hardware technology, the current server CPU is mostly multi-core and can handle multiple tasks at the same time, and systemd can start those irrelevant services concurrently, so the startup speed of the system has been greatly improved.
2) systemd starts the service on demand, while init starts all backend services and allows users to log in only after all the backend services are completed. This way of init will not only make the system start slowly, but also take up more system resources. The way adopted by systemd is to start a service only when it is requested, and the service will be turned off dynamically after use, so systemd has a great advantage in terms of startup speed and the use of system resources.
Systemd has two core concepts, unit and target. The management of the system by the systemd process is realized through individual units. For example, for a service, each service has a corresponding unit, and each unit has a configuration file, which is usually suffixed with .service as the file name, such as sshd service, whose configuration file is / usr/lib/systemd/system/sshd.service.
One of the more important units is called target unit, or target for short, and their configuration file names are suffixed with .target. In systemd, we use target to simulate different running levels of the system.
As mentioned above, CentOS 7 changed the system initialization process from init to systemd,init runlevels and changed it to target. What is the corresponding relationship between different runtime levels and goals? we use the following diagram to make a summary:
The commonly used runlevels are 3 (multi-user character mode) and 5 (multi-user graphical interface mode), which correspond to multi-user.target and graphical.target, respectively. Setting and switching different runlevels, CentOS 7 still supports init commands forward, but it is more recommended that we use systemd's management tool systemctl to do so.
1) to view the default operation of the current system, you can use the systemctl get-default command
# systemctl get-default
Multi-user.target
2) switch between different runlevels and use the systemctl [target name] command as an administrator
# systemctl isolate graphical.target switch to graphical interface
3) set the default run level of system startup
In CentOS 5 and 6, the default runlevel for system startup can be configured in the / etc/inittab file, but in CentOS 7, let's open this configuration file and take a look:
As you can see from the contents of the configuration file, "any configuration here has no effect on the system. Systemd replaces the run level with goals. By default, there are two main goals, multi-user.target is equivalent to run level 3. Target is equivalent to run level 5. Use systemctl get-default to see the current usage target, and use systemctl set-default Target.target to set the system default goal."
So let's try it with the following command, setting the system boot target to graphical
# systemctl set-default graphical.target
After setting up successfully, restart the computer and found that it really entered the GUI graphical interface mode.
The above is about the content of this article on "how to set the running level and goals of Linux". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.