Recently encountered a problem: when entering init 1, it gives an error: init: must be run as PID 1. I Entering ps and it turns out that /sbin/init has PID 1. How now can I use init?
1 Answer
You cannot use init. It is the wrong program for the job.
You need to un-learn the idea that init can be invoked as a normal command. The init programs where this is/was true are not the init program that you have. There are 4 init programs where one can invoke it as a normal command, and you are not using any of them. Rather, you are using BusyBox init, which if it detects that it has been invoked as anything other than process #1 on the system, prints that message and exits. It has no functionality for other than as process #1.
There is no telinit in BusyBox, either. Its init does not have a client/server interface over a FIFO.
To shut down, you must do something that eventually results in SIGPWR, SIGUSR1, SIGUSR2, or SIGTERM being sent to process #1. Note that, as with other system management toolsets, "single-user mode" (a misnomer since 1995) is not a shutdown target. One does not shut down to such a mode, and BusyBox init is not actually involved in enacting such a mode.
Rather, in systems using OpenRC on top of BusyBox init, this is a mode that is entirely the province of OpenRC mechanisms. openrc single changes to the mis-named "single" mode. (Using OpenRC's own init, which is not the case for you, there is a shutdown command that talks to it. But that's just a quite roundabout way of running openrc single, it turns out.)
Alpine Linux is documenting an outdated OpenRC, note. OpenRC itself does not have a single directory any more. That was removed in 2019. Furthermore, the rc command changed to openrc in 2014.
init" to do what, exactly?telinit? systemd manual says that itsinitwill forward totelinitif PID is not 1 (not being init, but being used to message init).command not found: telinitrc singleif alpine is still using openrc that might work, ... wiki.alpinelinux.org/wiki/Alpine_Linux_Init_System