ubuntu22 rc.local
时间: 2023-12-16 14:57:52 浏览: 243
rc.local文件下载
在Ubuntu 22.04中,如果你想要将一个程序添加到开机启动中,你可以通过修改rc.local文件来实现。在Ubuntu中,有两个rc.local文件,分别是/etc/rc.local和/etc/init.d/rc.local。这两个文件有一定的关联关系。
如果你在系统中找不到这两个文件,你可以自己创建一个rc-local.service文件,并在其中添加以下内容:
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
然后,你可以启动rc-local.service服务并将其设置为开机自启:
sudo systemctl start rc-local.service
sudo systemctl enable rc-local.service
最后,你可以创建/etc/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.
exit 0
记得给予脚本执行权限。通过以上步骤,你可以将程序添加到Ubuntu 22.04的rc.local中,并实现开机启动。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [ubuntu系统中/etc/rc.local和/etc/init.d/rc.local的区别详解](https://download.csdn.net/download/weixin_38564826/14890316)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [ubuntu没有rc.local文件](https://blog.csdn.net/qq_35002542/article/details/127999561)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文