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数年库安装

    MySQL系列 MySQL 的三大主要分支mysqlmariadbpercona Server MySQL系列2.2.2.1 MySQL 的三大主要分支mysqlmariadbpercona Serv ...

  2. LGP5795题解

    首先 \(k\) 大容易让我们想到 主席树&树套树&整体二分,而异或又让我们想到 01-Trie. 所以就有一个很明显的二分,二分一个 mid 看有多少个数不大于 mid. 然后发现 ...

  3. 逆置单链表(基于c语言)

    直接插入全部代码:(reverseLinklist函数是逆置操作) #include <stdio.h> #include <stdlib.h> #include <as ...

  4. 防止入侵 两步修改XP远程管理默认端口

    自Windows 2000开始,微软就提供一项终端服务(Terminal Server)这项服务可以将远程的桌面传递到本地.通过该服务,可视化的远程管理可以非常方便的实现.继Windows 2000之 ...

  5. C++设计模式 - 状态模式(State)

    状态变化模式 在组件构建过程中,某些对象的状态经常面临变化,如何对这些变化进行有效的管理?同时又维持高层模块的稳定?"状态变化"模式为这一问题提供了一种解决方案. 典型模式 Sta ...

  6. vue学习过程总结(06) - vue的数据存储store

    这个不知道能怎么叫不?现在对这块很迷.以下为个人理解 store是状态管理,是一个对象,有其属性和方法. 常见的值有:state/mutations/actions/getters, 这几个值的意思: ...

  7. Rocket Mq 常用API 及简单运维

    RocketMQ 常用API 消息 消息消费模式 消息消费模式由消费者来决定,可以由消费者设置MessageModel来决定消息模式. 消息模式默认为集群消费模式 consumer.setMessag ...

  8. BGP的四类属性详解

    BGP的四类属性 公认必遵(Well-known mandatory) 要求所有运行BGP协议的设备都必须能识别,且在更新消息中必须包含. Origin(起源) 属性 用来标识路由信息的来源. 如果路 ...

  9. Java 将CSV转为Excel

    CSV(Comma Separated Values)文件是一种纯文本文件,包含用逗号分隔的数据,常用于将数据从一个应用程序导入或导出到另一个应用程序.通过将CSV文件转为EXCEL,可执行更多关于数 ...

  10. linux管理用户(组)与相关问题处理

    相关联文件如下: /etc/passwd/etc/shadow/etc/group ================================= [切换当前用户为root]sudo -i [创建 ...