Ubuntu18.04 systemd开机自启
本文是该文的整理版。
Ubuntu18.04不再使用initd管理系统,改用systemd。为了像以前一样,在/etc/rc.local中设置开机启动程序,需要以下几步:
1、systemd默认读取/etc/systemd/system下的配置文件,该目录下的文件会链接/lib/systemd/system/下的文件。一般系统安装完/lib/systemd/system/下会有rc-local.service文件,即我们需要的配置文件。
创建软链接:
ln -fs /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service
cd /etc/systemd/system/
cat 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]
WantedBy=multi-user.target
Alias=rc-local.service
区块解释:
[Unit]:启动顺序与依赖关系。
[Service]:启动行为,如何启动,启动类型。
[Install] :定义如何安装这个配置文件,即怎样做到开机启动。
2、创建/etc/rc.local文件,赋可执行权限
touch /etc/rc.local
chmod 755 /etc/rc.local
3、编辑/etc/rc.local,添加需要开机启动的任务
#!/bin/bash
echo "test rc " > /var/test.log
4、执行reboot重启系统,然后查看test.log
sudo reboot
Ubuntu18.04 systemd开机自启的更多相关文章
- ubuntu18.04设置开机自启Django
设置开机自启: rc-local.server [Unit] Description=/etc/rc.local Compatibility ConditionPathExists=/etc/rc.l ...
- ubuntu-18.04 设置开机启动脚本
ubuntu-18.04 设置开机启动脚本 参阅下列链接 https://askubuntu.com/questions/886620/how-can-i-execute-command-on-sta ...
- ubuntu-18.04 设置开机启动脚本-亲测有效
ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本,通过下列简单设置后,可以使rc.local重新发挥作用. 2.将下列内容复制进rc-local.servi ...
- ubuntu16.04设置开机自启服务
网上说了开机自启有许多种方法: 1.最简单的是:在/etc/rc.local的exit 0前面加上你启动服务的脚本文件路径 注:这个脚本文件应写绝对路径! 2.网上:修改rc.local开头的#/bi ...
- Ubuntu-18.04设置开机启动脚本
参考:https://www.cnblogs.com/defifind/p/9285456.html http://www.cnblogs.com/airdot/p/9688530.html s ...
- Ubuntu18.04 设置开机进入命令行模式
首先来了解下启动级别(Runlevel): 指 Unix 或 类 Unix 操作系统下不同的运行模式,运行级别通常分为 7 级: 运行级别 0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启 ...
- Linux 7开机自启项查看并设置
在Linux6中查看及设置开机自启信息是使用chkconfig命令,Linux7中此命令已经被替代,接下来我们就来研究下Linux7中的区别所在. chkconfig --list Note: T ...
- Ubuntu 18.04 设置开机启动脚本 rc.local systemd
ubuntu18.04不再使用initd管理系统,改用systemd. ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本,通过下列简单设置后,可以使rc.l ...
- 树莓派 ubuntu16.04 安装SSH 配置SSH 开机自启SSH
入手个树莓派3B 装了 ubuntu 16.04 需要用到SSH 记录下 0.先获得树莓派IP 树莓派 使用网线连接路由器和树莓派 在路由器设置页面(一般是192.168.1.1具体看路由器的型号和设 ...
随机推荐
- Luogu P4768 [NOI2018]归程(Dijkstra+Kruskal重构树)
P4768 [NOI2018]归程 题面 题目描述 本题的故事发生在魔力之都,在这里我们将为你介绍一些必要的设定. 魔力之都可以抽象成一个 \(n\) 个节点. \(m\) 条边的无向连通图(节点的编 ...
- Thinkphp [美味]常用代码
//调试开关 function _initialize () { // 调试开关 C ( 'SHOW_PAGE_TRACE', TRUE ); } //判断 IS_AJAX && $t ...
- 【JZOJ5363】【NOIP2017提高A组模拟9.14】生命之树 Trie+启发式合并
题面 45 在比赛中,我只想到了45分的暴力. 对于一个树中点对,相当于在他们的LCA及其祖先加上这个点对的贡献. 那么这个可以用dfs序+树状数组来维护. 100 想法 我想到了可能要用trie树来 ...
- 2019-3-1-win10-uwp-发布旁加载自动更新
title author date CreateTime categories win10 uwp 发布旁加载自动更新 lindexi 2019-03-01 09:40:27 +0800 2019-0 ...
- js中的如何定位固定层的位置
需要获取一些HTML的对象的坐标来更灵活的设置目标层的坐标,这里可以通过用到document.body.scrollTop等属性,但是这些属性在xhtml的标准网页中或更简单的说就是带<!DOC ...
- sklearn之特征提取(文本特征)
1.引言 关于文本的提取有很多方法,本文主要探索下sklearn官方的文本特征提取功能. 2.文本特征提取 文本分析是机器学习算法的主要应用领域. 然而,原始数据,符号文字序列不能直接传递给算法,因为 ...
- 转: PHP的"::"、"->"和"=>"的区别
来自:http://blog.csdn.net/wgw335363240/article/details/20453379 1."::" 运算法 该运算符是调用一个类中的静态成员的 ...
- Hdu 4920矩阵乘法(内存访问的讲究)
题目链接 Matrix multiplication Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K ( ...
- HDU 1724 自适应辛普森法
//很裸的积分题,直接上模板 #include<stdio.h> #include<math.h> int aa, bb; //函数 double F(double x){ - ...
- LintCode_46 主元素
题目 给定一个整型数组,找出主元素,它在数组中的出现次数严格大于数组元素个数的二分之一. 样例 给出数组[1,1,1,1,2,2,2],返回 1 思路 首先 发现所给的数组是顺序排列好的. 用动态规划 ...