amazonlinux / amazon-linux-2023

Amazon Linux 2023
https://aws.amazon.com/linux/amazon-linux-2023/
Other
523 stars 39 forks source link

[Bug] - runlevel 1 (single-user mode) does not work #562

Open lukebakare opened 10 months ago

lukebakare commented 10 months ago

Describe the bug Entering single-user mode does not work and remains at level 5

To Reproduce Unlock the root account then enter rescue mode

sudo usermod -U root sudo init 1

Expected behavior who -r should return run-level 1

Output [root@al2023 ~]# who -r run-level 5 2023-11-28 18:17

Additional context When I attempt to enter single-user mode the output varies each time but will always have audit information:

[ 2659.572670] kauditd_printk_skb: 81 callbacks suppressed [ 2659.572688] audit: type=1305 audit(1701202140.362:181): op=set audit_pid=0 old=1643 auid=4294967295 ses=4294967295 subj=system_u:system_r:auditd_t:s0 res=1

thimslugga commented 9 months ago

For AL2023, I would recommend utilizing the systemctl isolate <desired_target>.target to switch to the desired target.

# To list both active and inactive systemd targets
systemctl list-unit-files --type target --all

OR

systemctl list-units --type target --all
# To switch to desired target from CLI
# Note that you will lose network connectivity when running the follow command. 
# Access via EC2 Serial Console.
systemctl isolate emergency.target

You are in emergency mode. After logging in, type "journalctl -xb" to view
system logs, "systemctl reboot" to reboot, "systemctGive root password for maintenance
(or press Control-D to continue): 

OR

# To switch to "rescue mode" target from CLI
systemctl isolate runlevel1.target

You are in rescue mode. After logging in, type "journalctl -xb" to view
system logs, "systemctlGive root password for maintenance
(or press Control-D to continue):
# After `systemctl isolate emergency.target` and login with root password
[root@i-0c2bbfd226ab10740 ~]#

[root@i-0c2bbfd226ab10740 ~]# who -r
         run-level    2024-01-04 17:48

[root@i-0c2bbfd226ab10740 ~]# runlevel
N N
lukebakare commented 8 months ago

These commands do not work with the on premise vmware image, it stays at runlevel 5.