如何从 /etc/inittab 启动 Linux shell
我们曾经在 /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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这具体取决于您运行的操作系统。这是一个在 RHEL/CentOS 上运行的示例。
这是其他人为类似的技巧所做的事情。
This depends on exactly what OS you are running. Here is an example which works on RHEL/CentOS.
Here is what someone else did for a similar trick.