linux修改引导_如何在Linux上更改系统引导目标

linux修改引导

Many Linux distros, such as RHEL/CentOS 7, Fedora, Ubuntu 16, are now using systemd instead of init as the init system. It is common for Linux users to set Linux to boot to "GUI" or "Text" mode. The old way of changing ‘/etc/inittab’ for choosing Linux runlevels is not working for sytemd. This post will introduce the way for systemd systems to select the "runlevels".

许多Linux发行版,例如RHEL / CentOS 7,Fedora,Ubuntu 16,现在都使用systemd代替init作为init系统。 Linux用户通常将Linux设置为引导到“ GUI”或“ Text”模式。 更改'/ etc / inittab'以选择Linux运行级别的旧方法不适用于sytemd。 这篇文章将介绍systemd 系统选择“运行级别”的方法。

For systemd, the concept of runlevels is replaced by the term "targets". For those that are familiar with the init runlevels, there is a "mapping" between the init runlevels and systemd targets:

对于systemd,运行级别的概念由术语“目标”代替。 对于那些熟悉init运行级别的用户,init运行级别和systemd目标之间存在一个“映射”:

┌─────────┬───────────────────┐
   │Runlevel │ Target            │
   ├─────────┼───────────────────┤
   │0        │ poweroff.target   │
   ├─────────┼───────────────────┤
   │1        │ rescue.target     │
   ├─────────┼───────────────────┤
   │2, 3, 4  │ multi-user.target │
   ├─────────┼───────────────────┤
   │5        │ graphical.target  │
   ├─────────┼───────────────────┤
   │6        │ reboot.target     │
   └─────────┴───────────────────┘

2 common targets are the most common ones:

最常见的目标是2个:

  • multi-user.target: analogous to runlevel 3, Text mode

    多用户目标:类似于运行级别3,文本模式
  • graphical.target: analogous to runlevel 5, GUI mode with X server

    graphic.target:类似于运行级别5,带有X服务器的GUI模式

引导后更改“运行级别” /目标 (Change the "runlevels"/targets after booting)

Even after the Linux system is booted to a target, you can change it to another target/runlevel. For example, to change Linux to "multi-user" target:

即使将Linux系统引导到目标后,也可以将其更改为另一个目标/运行级别。 例如,要将Linux更改为“多用户”目标:

# systemctl isolate multi-user.target

The command used is isolate. It starts the unit specified on the command line and its dependencies and stop all others.

使用的命令是isolate 。 它启动在命令行上指定的单元及其依存关系,并停止所有其他单元。

This is similar to changing the runlevel in a traditional init system using init 3.

这类似于使用init 3更改传统init系统中的运行级别。

更改启动“运行级别” /目标 (Change the boot "runlevels"/targets)

This changes the default boot target.

这将更改默认的引导目标。

For example, to make "multi-user.target" the default "runlevel", you can do:

例如,要将“ multi-user.target”设置为默认的“运行级别”,您可以执行以下操作:

# systemctl enable multi-user.target
# systemctl set-default multi-user.target

Next time you reboot, the default target booted to will be "multi-user".

下次重新引导时,引导到的默认目标将是“多用户”。

奖励:手动方式 (Bonus: the manual way)

This is not suggested way for changing the boot target. The command using systemctl is the best way. Just for those who are curious.

不建议使用这种方法更改引导目标。 使用systemctl的命令是最好的方法。 只是对于那些是好奇。

The default target is controlled by /etc/systemd/system/default.target which is a symbolic to the real .target file.

默认目标由/etc/systemd/system/default.target控制,这是真实.target文件的符号。

To set a default target, change the symbolic to point to the target you want.

要设置默认目标,请更改符号以指向所需的目标。

For example, to change the runlevel to ‘multi-user’ (3):

例如,要将运行级别更改为“多用户”(3):

# rm -f /etc/systemd/system/default.target; 
# ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target

翻译自: https://www.systutorials.com/change-systemd-boot-target-linux/

linux修改引导

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值