如何在 SUSE 12 Linux 中进入单用户模式？
单用户

> 
> 一篇了解如何在 SUSE 12 Linux 服务器中进入单用户模式的简短文章。
> 
> 
> 


![How to enter single user mode in SUSE 12 Linux](/data/attachment/album/201811/30/233149a2mpf33zhmclgzmj.png)


在这篇简短的文章中，我们将向你介绍在 SUSE 12 Linux 中进入单用户模式的步骤。在排除系统主要问题时，单用户模式始终是首选。单用户模式禁用网络并且没有其他用户登录，你可以排除许多多用户系统的情况，可以帮助你快速排除故障。单用户模式最常见的一种用处是[重置忘记的 root 密码](https://kerneltalks.com/linux/recover-forgotten-root-password-rhel/)。


### 1、暂停启动过程


首先，你需要拥有机器的控制台才能进入单用户模式。如果它是虚拟机那就是虚拟机控制台，如果它是物理机那么你需要连接它的 iLO/串口控制台。重启系统并在 GRUB 启动菜单中按任意键停止内核的自动启动。


![Kernel selection menu at boot in SUSE 12](/data/attachment/album/201811/30/233154hsdd90wk34kfx3kb.png)


### 2、编辑内核的启动选项


进入上面的页面后，在所选内核（通常是你首选的最新内核）上按 `e` 更新其启动选项。你会看到下面的页面。


![grub2 edits in SUSE 12](/data/attachment/album/201811/30/233156up79zzs77r9a9ddj.png)


现在，向下滚动到内核引导行，并在行尾添加 `init=/bin/bash`，如下所示。


![Edit to boot in single user shell](/data/attachment/album/201811/30/233157xmowuwj43ujouadw.png)


### 3、引导编辑后的内核


现在按 `Ctrl-x` 或 `F10` 来启动这个编辑过的内核。内核将以单用户模式启动，你将看到 `#` 号提示符，即有服务器的 root 访问权限。此时，根文件系统以只读模式挂载。因此，你对系统所做的任何更改都不会被保存。


运行以下命令以将根文件系统重新挂载为可重写入的。



```
kerneltalks:/ # mount -o remount,rw /
```

这就完成了！继续在单用户模式中做你必要的事情吧。完成后不要忘了重启服务器引导到普通多用户模式。




---


via: <https://kerneltalks.com/howto/how-to-enter-single-user-mode-in-suse-12-linux/>


作者：[kerneltalks](https://kerneltalks.com) 选题：[lujun9972](https://github.com/lujun9972) 译者：[geekpi](https://github.com/geekpi) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
A *Short article to learn how to enter a single-user mode in SUSE 12 Linux server.*

![](https://z5.kerneltalks.com/wp-content/uploads/2020/06/How-to-enter-single-user-mode-in-SUSE-12-Linux.png)

In this short article, we will walk you through steps that demonstrate how to enter a single-user mode in SUSE 12 Linux. Single user mode is always preferred when you are troubleshooting major issues with your system. Single user mode disables networking and no other users are logged in, you rule out many situations of the multi-user system and it helps you in troubleshooting fast. One of the most popular uses of single-user mode is to [reset forgotten root password](https://kerneltalks.com/linux/recover-forgotten-root-password-rhel/).

### 1. Halt boot process

First of all, you need to have a console of your machine to get into single-user mode. If its VM then VM console, if its physical machine then you need its iLO/serial console connected. Reboot the system and halt automatic booting of the kernel at the grub boot menu by pressing any key.

![](https://z5.kerneltalks.com/wp-content/uploads/2020/06/Grub-menu-in-SUSE-12.png)

### 2. Edit boot option of kernel

Once you are on the above screen, press

on selected kernel (which is normally your preferred latest kernel) to update its boot options. You will see be below screen.**e**

![](https://z5.kerneltalks.com/wp-content/uploads/2020/06/grub2-editor.png)

Now, scroll down to your booting kernel line and add `init=/bin/bash`

at the end of the line as shown below.

![](https://z5.kerneltalks.com/wp-content/uploads/2020/06/Edit-to-boot-in-single-user-shell.png)

### 3. Boot kernel with edited entry

Now press `Ctrl-x`

or `F10`

to boot this edited kernel. The kernel will be booted in single-user mode and you will be presented with hash prompt i.e. root access to the server. At this point in time, your root file system is mounted in read-only mode. So any changes you are doing to the system won’t be saved.

Run below command to remount root filesystem as re-writable.

```
kerneltalks:/ # mount -o remount,rw /
```

And you are good to go! Go ahead and do your necessary actions in single-user mode. Don’t forget to reboot the server or type `exit`

to boot into normal multiuser mode once you are done.

## Share Your Comments & Feedback: Cancel reply