启动时运行命令
我的问题如下:我想修改我的Ubuntu LiveCD在启动时运行几个命令,但我是Ubuntu开发的新手,不知道如何做到这一点。 每次启动Ubuntu时运行这些命令的正确方法是什么?
这是前。 命令:
sudo rm /home/ubuntu/Desktop/examples.desktop sudo perl -e 'print("[DesktopEntry]\nVersion=1.0\nType=Application\nTerminal=false\nIcon=xinput_calibrator\nName=Calibraion\nExec=env /usr/bin/xinput_calibrator\n");' > /home/ubuntu/Desktop/Calibrate.desktop sudo /home/ubuntu/Desktop/Calibrate.desktop
编辑!!!
我实际上尝试过修改rc.local文件,它现在看起来像这样:
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. sudo rm /home/ubuntu/Desktop/examples.desktop sudo perl -e 'print("[DesktopEntry]\nVersion=1.0\nType=Application\nTerminal=false\nIcon=xinput_calibrator\nName=Calibraion\nExec=env /usr/bin/xinput_calibrator\n");' > /home/ubuntu/Desktop/Calibrate.desktop sudo /home/ubuntu/Desktop/Calibrate.desktop exit 0
但我仍然不知道它是否会起作用。 在构建iso之前我想确定一下。
编辑2 !!!
我使用本教程构建了iso文件: https : //help.ubuntu.com/community/LiveCDCustomization我已经完成了以下步骤:
- 提取CD .iso内容
- 解压缩桌面系统
- 然后我编辑了rc.local文件并保存了
- 组装文件系统(我已经忽略了“重新生成清单”点)
现在我得到了错误
没有找到init。 尝试传递init = bootarg
在启动我的LiveCD时。
传递init = bootarg导致:
/ bin / sh:bootarg:找不到
我究竟做错了什么?
谢谢
在Ubuntu启动时执行脚本
Edit /etc/rc.local and add your commands The script must always end with exit 0
在重新启动Ubuntu时执行脚本
Put your script in /etc/rc0.d Make it executable (sudo chmod +x myscript) Note: The scripts in this directory are executed in alphabetical order
脚本的名称必须以K99开头才能在正确的时间运行。
我不确定这会对你的情况有所帮助,但我会再看一些,看看我能想出什么。
在关机时执行脚本
Put your script in /etc/rc6.d Make it executable (sudo chmod +x myscript) Note: The scripts in this directory are executed in alphabetical order
脚本的名称必须以K99开头才能在正确的时间运行。
之前已经问过这个问题的链接。 如何在ubuntu 12.04上登录时运行命令?
这是一个拙劣的构建。 换句话说,你需要使用另一张光盘是有问题的。 如果您决定使用其他光盘,请确保使用其他类型以省略其他问题。 您需要确保这样做,以便我们继续进行故障排除。 这是第一步。 Botched构建非常频繁,并且在尝试执行此类操作时应始终是进行故障排除的第一步。 如果你尝试这个并且你仍然得到同样的错误回到我身边我有一个朋友在常规上做这种事情我会把它传递给他,看看他的想法。 但在此期间忙碌起来。
非常尊重,
Matthew Kaulfers