linux修改运行级别_如何更改Linux中的运行级别?

linux修改运行级别

linux修改运行级别

Run Level is a preset operating state in Linux systems. Different run levels have different behavior. How can we change these run levels easily? What are these run levels?

运行级别是Linux系统中的预设操作状态。 不同的运行级别具有不同的行为。 我们如何轻松更改这些运行级别? 这些运行级别是多少?

运行级别 (Run Levels)

We will explain the run levels and their meanings in this section

我们将在本节中解释运行级别及其含义

  • Run Level 0 is shutdown position. Linux system is powered off. Linux systems run levels transitioned to 0 to shut down.

    运行级别0为停机位置。 Linux系统下电。 Linux系统的运行级别已转换为0以关闭。

  • Run Level 1 is single-user mode there is no network and used rarely

    运行级别1是单用户模式,没有网络,很少使用

  • Run Level 2 is multi-user mode but there is no network file system. This level is used rarely too

    运行级别2是多用户模式,但是没有网络文件系统。 这个级别也很少使用

  • Run Level 3 is the default mode for most of the Linux servers. There is no gui but all other services and features are functional

    对于大多数Linux服务器,运行级别3是默认模式。 没有gui,但所有其他服务和功能均正常运行

  • Run Level 4 is user-defined

    运行级别4是用户定义的

  • Run Level 5 is a multi-user GUI mode default for most of the user systems.

    对于大多数用户系统,运行级别5是默认的多用户GUI模式。

  • Run Level 6 is used to reboot the system

    运行级别6用于重新引导系统

列出运行级别(List Run Levels)

Run levels are stores inside the /etc and named with rc0.d, rc1.d , rc.. to the rc6.d. We can list these run level directories and their content with the ls command like below.

运行级别存储在/etc内部,并以rc0.drc1.drc..命名为rc6.d 我们可以使用ls命令列出这些运行级别目录及其内容,如下所示。

$ ls /etc/rc*
List Run Levels
List Run Levels
列出运行级别

We can see that there are scripts which starts with K , S . K means kill and the given script is used to stop or kill related service. S means start` and the given script will start the related service.

我们可以看到存在以KS开头的脚本。 K表示杀死,并且给定脚本用于停止或终止相关服务。 S表示启动`,并且给定脚本将启动相关服务。

如何更改运行级别 (How To Change Run Level)

Run levels can be changed easily. To change run level root privilege is required.

运行级别可以轻松更改。 要更改运行级别,必须具有root用户特权。

$ init 3

This will change the current run level to run level 3

这会将当前运行级别更改为运行级别3

启动运行级别6 (Boot With Run Level 6)

We can reboot Linux system by changing to run level 6 like below

我们可以通过更改为如下所示的运行级别6来重启Linux系统

$ init 6

This is the same as reboot command

这与重新启动命令相同

使用Systemctl运行级别(Run Level  With Systemctl)

In the old days, init was the ruler of the run levels. But times have changed. Now systemctl is the emperor. All most all run-level related operations are done with systemctl.

在过去,init是运行级别的标尺。 但是时代变了。 现在systemctl是皇帝。 所有大多数与运行级别相关的操作都是通过systemctl完成的。

LEARN MORE  Linux chkconfig Command Tutorial with Examples
了解更多Linux chkconfig命令教程和示例

使用Systemctl获取当前运行级别(Get Current Run Level With Systemctl)

We can get the current run level with systemctl like below

我们可以使用systemctl来获得当前的运行级别,如下所示

$ systemctl get-default                                                                                                 
multi-user.target
  • As you guess multi.user is equal to run level 3

    您猜到multi.user等于运行级别3

使用Systemctl更改运行级别 (Change Run Level With Systemctl)

We can change run level with systemctl by providing systemctl targets like below

我们可以通过提供如下的systemctl目标来使用systemctl更改运行级别

$ systemctl isolate graphical.target
  • isolate parameters change the run level to graphical.target

    隔离参数将运行级别更改为graphic.target

使用Systemctl设置默认运行级别 (Set Default Run Level With Systemctl)

We can set default run level with systemctl. Default run level is start when the computer boot. We want to not start GUI we can change the default run level to multi-user.target like below

我们可以使用systemctl设置默认运行级别。 默认运行级别是计算机启动时启动。 我们不想启动GUI,我们可以将默认运行级别更改为multi-user.target,如下所示

$ systemctl set-default multi-user.target
 

翻译自: https://www.poftut.com/change-run-levels-linux/

linux修改运行级别

  • 4
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值