如何从 /etc/inittab 启动 Linux shell

发布于 2024-09-07 07:05:16 字数 518 浏览 2 评论 0原文

我们曾经在 /etc/inittab 中有两个条目:

::sysinit:/etc/init.d/rcS
ttyS0::respawn:-/bin/sh

rcS 是一个 shell 脚本,通常会启动我们的应用程序,但在特殊情况下,我们调用“return”来终止它,这显然让 /bin/sh 接管 tty 作为我们得到了一个 shell 提示符,可以在其中进行一些维护。

现在 inittab 看起来像这样:

::once:/etc/init.d/rcS

我们现在通过在 rcS 脚本中执行“/bin/bash -i”来启动 shell,因为我们不想总是运行通常从不使用的第二个 shell(由于内存限制) 。

但创建的 bash 不具备作业控制功能,这是非常有限的。

所以我的问题是,我是否可以像我们之前的解决方案中处理 init 的方式创建一个 shell(并且可能终止 rcS 脚本),以便我再次获得一个具有作业控制的 shell?

We used to have two entries in our /etc/inittab:

::sysinit:/etc/init.d/rcS
ttyS0::respawn:-/bin/sh

rcS is a shell script which normally starts our application, but in a special case we called "return" to terminate it which apparently lets the /bin/sh take over the tty as we got a shell prompt where we could do some maintenance.

Now the inittab looks like this:

::once:/etc/init.d/rcS

We now start the shell by executing "/bin/bash -i" in the rcS script, as we don't want to always run a second shell (due to memory constraints) which is normally never used.

But the created bash doesn't feature job control, which is very limiting.

So my question is, can I create a shell (and maybe terminate the rcS script) the same way the init processed did in our previous solution so that I get again a shell with job control?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江湖正好 2024-09-14 07:05:16

这具体取决于您运行的操作系统。这是一个在 RHEL/CentOS 上运行的示例。

6:2345:respawn:/sbin/mingetty --autologin root tty6

这是其他人为类似的技巧所做的事情。

openvt -f -c 12 -w -- sh -c "unicode_start; echo -e '$NORPT'; exec $LOGINSH" >/dev/tty1

This depends on exactly what OS you are running. Here is an example which works on RHEL/CentOS.

6:2345:respawn:/sbin/mingetty --autologin root tty6

Here is what someone else did for a similar trick.

openvt -f -c 12 -w -- sh -c "unicode_start; echo -e '$NORPT'; exec $LOGINSH" >/dev/tty1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文