kali添加开机自启

采用systemd的方法,kali默认是没有rc.local的,需要自己创建。本方法也适用于ubuntu 18.04 64bit

改写rc-local.service 文件

先从lib中拿出模板文件进行更改

sudo cp /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service

再vim修改

sudo vim /etc/systemd/system/rc-local.service

主要是添加[install]复制最下面的[install]即可

#  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

创建/etc/rc.local文件

sudo vim /etc/rc.local
#!/bin/bash
#!/bin/bash
#
# 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.
/home/ki/桌面/frp_0.36.2_linux_amd64/frpc -c /home/ki/桌面/frp_0.36.2_linux_amd64/frpc.ini &
exit 0

注意,注释到执行代码这片区域中间不要有空行。不然该服务会将空行当命令执行,所以就会报错。命令后面我加上& 是表示在后台执行

设置执行权限

sudo chmod a+x /etc/rc.local

检查脚本是否正确

含义分别是重载服务,启动服务,查看服务状态

sudo systemctl enable rc-local
sudo systemctl start rc-local.service
sudo systemctl status rc-local.service

可能出现的问题

  • 出现active,但是下面日志出现报错

则你的systemd服务顺利执行了。但是你的/etc/rc.local脚本有问题。自己执行下这个命令看看能不能正确执行该脚本。不能那就检查脚本代码,注意不要出现空行。重新检查文件执行权限

./etc/rc.local
  • 没显示active

那么就是你的/etc/systemd/system/rc-local.service 写的不对。重新检查下,特别是[install]部分

kali添加开机自启[亲测有效]的更多相关文章

  1. Redis单机部署、添加开机自启、配置参数

    1.Redis简介 redis是使用C语言编写的开源的,支持网络,基于内存,可持久性的键值对存储数据库,2013年5月之前,Redis是最流行的键值对存储数据库,Redis采用内存数据集,支持多种数据 ...

  2. Centos 7 redis、tomcat、Spring Boot添加开机自启服务

    一.redis添加开机自启 1.添加服务配置文件 [root@test system]# vim /etc/systemd/system/redis-server.service 2.服务配置文件内容 ...

  3. ubuntu添加开机自启和sysv-rc-conf

    此文ubuntu使用sysvinit,而非upstart UBUNTU添加开机自动启动程序方法 1. 开机启动时自动运行程序    Linux加载后, 它将初始化硬件和设备驱动, 然后运行第一个进程i ...

  4. ubuntu-18.04 设置开机启动脚本-亲测有效

    ubuntu-18.04不能像ubuntu14一样通过编辑rc.local来设置开机启动脚本,通过下列简单设置后,可以使rc.local重新发挥作用. 2.将下列内容复制进rc-local.servi ...

  5. zabbix添加开机自启

    原文链接:https://www.cnblogs.com/zydev/p/6888805.html 1. zabbix客户端的系统服务脚本 1.1 拷贝启动脚本 zabbix的源码提供了系统服务脚本, ...

  6. linux中添加开机自启服务的方法

    往文件/etc/rc.d/rc.local中追加内容即可,如: /mongodb/start_mongoDB.sh

  7. 【centos7】添加开机启动服务/脚本

    一.添加开机自启服务 在centos7中添加开机自启服务非常方便,只需要两条命令(以Jenkins为例): systemctl enable jenkins.service #设置jenkins服务为 ...

  8. centos7如何添加开机启动服务/脚本

    一.添加开机自启服务 在centos7中添加开机自启服务非常方便,只需要两条命令(以Jenkins为例): systemctl enable jenkins.service #设置jenkins服务为 ...

  9. Centos 下添加开机自启动服务和脚本

    最近刚玩Centos7的系统,跟Centos6还是很多方面有改变的,这里记录一下怎么在Centos7下添加开机自启动脚本和服务的方法. 1.添加开机自启服务 我这里以docker 服务为例,设置如下两 ...

随机推荐

  1. MySQL-DB-封装-入门版

    <?php class MysqlDb{ public $host = "127.0.0.1"; public $user = "root"; publi ...

  2. Java的jstat命令使用详解

    jstat命令简介 jstat(Java Virtual Machine Statistics Monitoring Tool)是JDK提供的一个可以监控Java虚拟机各种运行状态信息的命令行工具.它 ...

  3. 手写 Vue2 系列 之 编译器

    前言 接下来就要正式进入手写 Vue2 系列了.这里不会从零开始,会基于 lyn-vue 直接进行升级,所以如果你没有阅读过 手写 Vue 系列 之 Vue1.x,请先从这篇文章开始,按照顺序进行学习 ...

  4. mysql 完整备份和恢复

    mysql 完整备份和恢复   一.MySQL完整备份操作 1.直接打包数据库文件夹 创建数据库auth: MariaDB [(none)]> create database auth;Quer ...

  5. LGP2891题解

    题目大意 有 \(n\) 只奶牛,\(q\) 种食物和 \(p\) 种饮料,每只奶牛喜欢一些饮料和食物,但只能那一种,求最小配对数量. 首先来看一下这道题的简化版:没有饮料,该怎么做呢? 我会!裸的二 ...

  6. VS2010 查看代码编辑器中的变量

    查看变量的使用情况 1.选中代码中的变量 2.右键 Find Usages

  7. Mybatis——xml配置

    注:该文档参考了 https://mybatis.org/mybatis-3/zh/configuration.html 狂神的视频:https://www.bilibili.com/video/BV ...

  8. 在Ubuntu 18.04上使用msmtp和gmail,git-sendemail发送patch给kernel

    这是我第一次发送patch给kernel,虽然仅仅是一个test的patch,但我也觉着很新奇,这也是自己的一个小小的进步. 如下是从各种网站上学到的如何发送patch的总结. 1. Create g ...

  9. python练习册 每天一个小程序 第0005题

    1 # -*-coding:utf-8-*- 2 __author__ = 'Deen' 3 ''' 4 题目说明: 你有一个目录,装了很多照片,把它们的尺寸变成都不大于 iPhone5 分辨率的大小 ...

  10. 题解0007:小木棍(P1120)

    (错误记录) 题目链接:https://www.luogu.com.cn/problem/P1120 题目描述:几根同样长的木棍,小冥把它们随意砍成了n段: 然后他又吃饱了撑的想把木棍拼上: 但是这个 ...