A lot of embedded systems are running Linux on platforms like Raspberry Pi. Since Linux is fully functional from a command line and fully network-capable, it is possible to run servers that you’ve never had physical access to.
There are a few problems, though. Sometimes you really need to reboot the box physically. You also need to be at the console to do things like totally install a new operating system. Or do you? Over on GitHub, user [marcan] has a C program and a shell script that allows you to take over a running system without using any software on the root filesystem. It starts an ssh server and you can remotely unmount the main drive, do any maintenance you want and –presumably–reboot into a new operating system.
The key is to create a temporary file system (which lives in RAM0 and copy a system rescue CD to it. The system also has to use systemv-style init so that the command “telinit u ” will cause init to rerun itself. The init process is the program the bootloader really executes and always has PID 1.
However, with [marcan’s] script, the file system is scrambled around and a script built on the fly by the takeover script replaces init. So when init reruns itself, it really executes the script which eventually runs in the included fakeinit which just sits around and waits.
Usually, the Linux boot process just works and you might not be aware of all that goes on with it. But if you do know, you can pull tricks like this. Raspbian, for example, derives from Debian, so you can learn more about the boot process by looking at the Debian documentation.
Of course, if your distribution has switched to systemd, you’ll have to try a different tack (we did a post about the Linux kernel awhile back that led to a lot of comments about the systemd war). Understanding the Linux boot system is one pillar to Linux wizardry. Learning more about the kernel and system calls are two more.