0

Today I try to use the way that I've known for several years to enter the Single User mode: enter the edit mode of grub and add single at the end of line of kernel and type F10.

I thought I could enter the Single User mode without typing password but to my surprise, it asked me to type the root password. I don't know why because I always used this way to rescue my linux system, for example, if I lost the root password, I could use this way to make a new root password.

But now things changed...

So Ubuntu has blocked this non-password single user mode?

Yves
  • 1,358

2 Answers2

1

So Ubuntu has blocked this non-password single user mode?

No. The single user mode does ask a password if there is one set for "root" but that is not the default.

to type the root password

Ubuntu does not work with "root" and the password for "root" is set/disabled on installation.

And then there is systemd. See if ...

grep ExecStart /usr/lib/systemd/system/rescue.service

returns a "sulogin" then that is a reason for asking for a password. The parameters in that line will explain what is asked.


The man page for sulogin explains its behaviour:

sulogin is invoked by init when the system goes into single-user mode.

The user is prompted:

      Give root password for system maintenance
      (or type Control-D for normal startup):

If the root account is locked and --force is specified, no password is required.
Rinzwind
  • 309,379
0

If you don't want single user mode to prompt for a password, the file responsible is /lib/systemd/system/rescue.service, specifically the ExecStart line, however, it's inadvisable to edit this file directly as it may get overwritten.

Instead, we need to create an override file for it like this:

systemctl edit rescue.service

This will open a text editor. Add these lines:

[Service]
ExecStart=
ExecStart=-/bin/bash

(FYI: the blank ExecStart= is mandatory to unset the existing value before setting it to what we want)

Now save the file, and it will create a file /etc/systemd/system/rescue.service.d/override.conf the contents of which will override /lib/systemd/system/rescue.service

You will also need to make sure the package friendly-recovery is uninstalled as it will prevent this from working

apt purge friendly-receovery

Uninstalling the package should automatically invoke update-grub but if it doesn't you may need to run it manually.

If you want to revert to the default behavior (prompt for root password), delete the /etc/systemd/system/rescue.service.d/override.conf file you created and (if desired) reinstall the friendly-recovery package.