rc.local(ubuntu18.04)

系统自带服务/lib/systemd/system/rc-local.service

软连接为 /lib/systemd/system/rc.local.service -> rc-local.service

#  SPDX-License-Identifier: LGPL-2.1+
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

可以看到此文件缺少[install]部分,为他加上。

[Install]
WantedBy=multi-user.target

输入systemctl enable rc-local.service

系统启动时将执行/etc/rc.local文件里的内容

16.10开始不再有/etc/rc.local文件

创建

printf ‘%s\n‘ ‘#!/bin/bash‘ ‘exit 0‘ | sudo tee -a /etc/rc.local
vim /etc/rc.local

添加以下内容用于测试

#!/bin/bash 

touch /var/lock/subsys/local

source /etc/profile

echo `date`,"ok" >>/tmp/test-rc-local.log
sudo chmod +x /etc/rc.local

重启后看效果

原文地址:https://www.cnblogs.com/wintersoft/p/9942672.html

时间: 2024-08-03 21:16:10

rc.local(ubuntu18.04)的相关文章

ubuntu 18.04 配置 rc.local

ubuntu 18.04 配置 rc.local:https://blog.csdn.net/a912952381/article/details/81205095 Ubuntu /etc/rc.local 不存在: https://blog.csdn.net/weixin_43599336/article/details/85970601 原文地址:https://www.cnblogs.com/dhcn/p/10660465.html

Ubuntu 16.04设置rc.local开机启动命令/脚本的方法(通过update-rc.d管理Ubuntu开机启动程序/服务)

注意:rc.local脚本里面启动的用户默认为root权限. 一.rc.local脚本 rc.local脚本是一个Ubuntu开机后会自动执行的脚本,我们可以在该脚本内添加命令行指令.该脚本位于/etc/路径下,需要root权限才能修改. 该脚本具体格式如下: #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the scrip

Ubuntu 18.04 rc.local systemd设置

创建软链接 ln -fs /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service 编辑配置文件 vim /etc/systemd/system/rc-local.service # SPDX-License-Identifier: LGPL-2.1+ # # This file is part of systemd. # # systemd is free software; you can redist

理解Linux系统/etc/init.d目录和/etc/rc.local脚本

本文英语版本来自:http://www.ghacks.net/2009/04/04/get-to-know-linux-the-etcinitd-directory/ 以下内容是作者自己的翻译版本,如需转载到CSDN外其他网站,请注明本文链接.  一.关于/etc/init.d 如果你使用过linux系统,那么你一定听说过init.d目录.这个目录到底是干嘛的呢?它归根结底只做了一件事情,但这件事情非同小可,是为整个系统做的,因此它非常重要.init.d目录包含许多系统各种服务的启动和停止脚本.

理解Linux系统/etc/init.d目录和/etc/rc.local脚本(转载)

本文英语版本来自:http://www.ghacks.net/2009/04/04/get-to-know-linux-the-etcinitd-directory/ 以下内容是作者自己的翻译版本,如需转载到CSDN外其他网站,请注明本文链接.  一.关于/etc/init.d 如果你使用过Linux系统,那么你一定听说过init.d目录.这个目录到底是干嘛的呢?它归根结底只做了一件事情,但这件事情非同小可,是为整个系统做的,因此它非常重要.init.d目录包含许多系统各种服务的启动和停止脚本.

Ubuntu:/etc/rc.local 可执行权限问题

VmWare 11.1.2 安装Ubuntu 12.04系列版本, /etc/rc.local 有可执行权限. 安装Ubuntu 14.04系列版本,发现 /etc/rc.local 没有可执行权限,导致写入其中命令无法执行. VmWare 11.0.0  安装Ubuntu 12.04和14.04系列版本,/etc/rc.local 都有可执行权限 VirtualBox 安装Ubuntu 12.04和14.04系列版本,/etc/rc.local 都有可执行权限 /etc/rc.local 中说

Ubuntu18.04美化主题(mac主题)

前端时间Ubuntu18.04LTS发布,碰巧之前用的Ubuntu16.04出了一点问题,懒得解决,索性就换了Ubuntu18.04. 成果: 参考博客:https://www.cnblogs.com/feipeng8848/p/8970556.html 下面开始进行美化配置: 安装主题工具:GNOME Tweaks (Ubuntu18.04对软件中心也做了强化,也可以去软件中心进行下载) sudo apt-get update sudo apt-get install gnome-tweak-

ubuntu18.04虚拟机突然不能上网问题解决办法

周末在家啃书学docker,win10上装的虚拟机,ubuntu18.04,突然执行apt-get update报错,域名无法解析,怀疑是dns文件有问题,折腾了很久,各种百度,修改dns文件,仍然报错,ping www.baidu.com报错.又开始怀疑是不是网络本身有问题,修改网络配置,仍然不起作用. 以系统报错的关键字搜索,尝试网友提供的方法均以失败告终: 后来,搜索"ubuntu18.04虚拟机不能联网",突然,看到一篇博客,终于解决了问题,哈哈哈: 转载链接:https://

ubuntu18.04上使用LLDB调试Chromium_Android

###动机###Chromium_Android源代码庞大且复杂.在调试器LLDB下能帮助我们更好的理解代码流程.介绍使用LLDB调试器调试android上chromium的C++代码. [1] 编译Chromium时,记得修改编译选项:-g -O0, 使得编译器做更少的优化,便于调试.使用attach方式调试(因此进程在启动过程中暂时不能调试).查看进程PID:adb shell ps -A | grep chrome启动lldb-server:adb shell /system/bin/ll