ubuntu中rc.local怎么开启和使用


在Ubuntu中,rc.local文件默认是不启用的,如果需要启用并使用rc.local文件,可以按照以下步骤操作:

    打开终端,输入以下命令打开rc.local文件进行编辑:
sudo nano /etc/rc.local
    在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.# Print the IP address_IP=$(hostname -I) || trueif [ "$_IP" ]; thenprintf "My IP address is %s\n" "$_IP"fiexit 0

    保存并退出rc.local文件。在nano编辑器中,按下Ctrl+X,然后按Y确认保存,最后按Enter键确认文件名。

    授予rc.local文件执行权限,输入以下命令:

sudo chmod +x /etc/rc.local
    最后,重新启动系统以应用更改,输入以下命令:
sudo reboot

之后,系统启动时,rc.local文件中添加的命令或脚本将会自动执行。


上一篇:android中jni调用的方法是什么

下一篇:oracle数据误删除如何恢复


ubuntu
Copyright © 2002-2019 测速网 www.inhv.cn 皖ICP备2023010105号
测速城市 测速地区 测速街道 网速测试城市 网速测试地区 网速测试街道
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!

热门搜索 城市网站建设 地区网站制作 街道网页设计 大写数字 热点城市 热点地区 热点街道 热点时间 房贷计算器